Open sobrinho opened 12 years ago
I forgot, we are workarounding this issue using that bizarre code:
class Person < ActiveRecord::Base
belongs_to :personable, :polymorphic => true
accepts_nested_attributes_for :personable
def personable_attributes=(personable_attributes, options = {})
self.personable ||= personable_type.constantize.new
personable.localized.assign_attributes(personable_attributes, options)
end
end
This version is more ugly than first option, do not work for all cases and assume we want localized version all the time but it's working for now ;)
I don't have an idea off the top of my head, but I'll try to search and think what can be done. Meanwhile if you want to send a failing test case, would help :). Thanks!
Any news on this one?
Not actually, I haven't stopped to put much thought on it :)
I may have some time available to get back to it in a couple weeks, in the meanwhile any help would appreciated. Thanks!
Hey mate,
Seems like we have a "integration" problem with active record and i18n alchemy but I'm not sure.
Just to you follow my production code, we can't accept nested attributes for polymorphic associations:
It's ok, not the best solution but you can work around it:
And, it just works now:
But, if we try to use localized version:
The alchemy offending code is that:
This won't work because polymorphic associations do not have the class defined.
I'm not sure about using
build_#{association_name}
because we will mutate the object, but maybe that is expected if we are receiving the#{association_name}_attributes
in a localized proxy.Anyway, I need this polymorphic association to be assigned localized.
Thoughts? :-)