This line o' code in autosave_association.rb is a little bit weird
imo.
attribute = "#{reflection.name}_#{attribute}"
Line 252 on master at the moment.
It's used in at least two places I can tell (I haven't looked very
hard), accepts_nested_attributes and validates_associated. The string
that is generated is then applied to #errors on the parent record as
the base name. So, for example:
class Profile < AR::Base
has_one :address
accepts_nested_attributes_for :address
end
class Address < AR::Base
validates_presence_of :city
end
p = Profile.new
p.build_address
p.save
p.errors.full_messages
# => ['Address City is invalid']
#or something like that.
The issue is that "Address City" is meaningless to our users. How
many of you label your "City" text field as "Address City" on your
"Profile" form?
Was this added in order to disambiguate if the same attribute exists
on both the parent and the child? If so, can we do away with that? We
can't save bad developers from themselves.
Changing the above line to
attribute = "#{attribute}"
only breaks a handful of tests and only in TestNestedAttributes and
TestAutosaveAssociation, so I don't think it's widely used.
Thoughts?
Thanks,
Josh
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---