fast_jsonapi icon indicating copy to clipboard operation
fast_jsonapi copied to clipboard

WIP: make belongs_to polymorphic use `id_method_name`

Open doits opened this issue 6 years ago • 1 comments

fixes #382

This is more or less a WIP to see what you guys say about this.

Some remarks:

  • There could be a short cut to not fetch the associated record in case of belongs_to without a object block. In this specific case it might be enough to use the xxx_type column and &:id_method_name on the parent. This would remove the need to instantiate the associated record in that case. Though then the fetch_id method could not be used and the belongs_to case would be a completely separated case.
  • run_key_transform is not yet cached (like in other methods)

What do you say about this in general?

I could think of a second way to make belongs_to have a complete different logic, which might speed belongs_to up though (if there is no need to fetch the association), but not sure if this is the way to go or if this makes the class too complex and if the xxx_type column is enough to get the class (or if there are some edge cases where this does not work).

doits avatar Jan 26 '19 13:01 doits

This should probably also be updated to work with has_one

davidcelis avatar May 08 '19 17:05 davidcelis