You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rails uses .polymorphic_name to derive the value for the {association}_type attribute value. It's fairly common, if not documented/supported, to override polymorphic_name for AR Models that need to store or support custom translations between the attribute value and ruby class names.
Unfortunately, Graphiti::Adapters::Persistence::Associations directly emits the ruby class name for the _type attribute without consulting polymorphic_name.
Luckily, this behavior lives on the adapter, so it can be overridden. However, I would like to push this into the AR adapter so that the rails adapter more closely follows Rails' own behavior.
I think my proposal would be for the Assocations 'base' adapter to have a polymorphic_name method which evaluates to class.name, thus allowing the AR adapter to override as class.polymorphic_name. Unless anyone sees any reason for this to be something that lives on the resource or resource proxy?
The text was updated successfully, but these errors were encountered:
Rails uses
.polymorphic_name
to derive the value for the{association}_type
attribute value. It's fairly common, if not documented/supported, to overridepolymorphic_name
for AR Models that need to store or support custom translations between the attribute value and ruby class names.Unfortunately,
Graphiti::Adapters::Persistence::Associations
directly emits the ruby class name for the _type attribute without consultingpolymorphic_name
.graphiti/lib/graphiti/adapters/persistence/associations.rb
Line 64 in 14e84ef
Luckily, this behavior lives on the adapter, so it can be overridden. However, I would like to push this into the AR adapter so that the rails adapter more closely follows Rails' own behavior.
I think my proposal would be for the Assocations 'base' adapter to have a polymorphic_name method which evaluates to
class.name
, thus allowing the AR adapter to override asclass.polymorphic_name
. Unless anyone sees any reason for this to be something that lives on the resource or resource proxy?The text was updated successfully, but these errors were encountered: