It seems Rails will only validate an existing invalid nested model if the nested model's attributes have changed.
With the following models:
class Person < ActiveRecord::Base
has_many :addresses
accepts_nested_attributes_for :addresses
end
class Address < ActiveRecord::Base
belongs_to :person
validates_presence_of :street
end
The following code for example, will save and return true:
p = Person.first
p.update_attributes({:first_name => "Bryan", :addresses_attributes=>{"0"=>{:street=>"", :id => 1}})
Is there a way to validate the nested model as if it's attributes have changed? ( while retaining errors )
saveorsave!methods.update_attributesis for special cases, and (I would have to look but) think it doesn't trigger certain checks that the straight-upsavemethods do.