This project is archived and is in readonly mode.
Different nested validations should not be ignored
-
Eloy Duran
- Milestone set to 2.3.6
- Assigned user set to Eloy Duran
-
Eloy Duran
- State changed from new to hold
- Assigned user changed from Eloy Duran to José Valim
This is intended behavior, as can be see on this line (unless errors.on(attribute)): http://github.com/rails/rails/blob/2-3-stable/activerecord/lib/acti...
I'm re-assigning this to José as he knows more about the current state of handling errors and I'll have a chat about it with him.
-
José Valim
- State changed from hold to open
- Milestone cleared.
It will get one validation error in the parent, but both children will be invalid. This is the correct behavior since you don't want error messages for to show several times the same error message:
- Product name can't be blank
- Product name can't be blank
On the other hand, if the same attribute has two different errors, just the first will be shown. So we have a bug, but it's reproduced in a scenario slightly different:
class Store < ActiveRecord::Base has_many :products accepts_nested_attributes_for :products end class Product < ActiveRecord::Base belongs_to :store validates_presence_of :price validates_numericality_of :price end s = Store.new s.products.build(:price => nil) s.products.build(:price => nil) s.valid? # It shows no information about numericality s.errors.full_messages => ["Products price can't be blank"]This can be fixed in master (3.0), but not easily in 2.3.6, so I'm reassigning the milestone (thanks Eloy!)
-
José Valim
- Title changed from accepts_nested_attributes_for overwriting nested validations to Different nested validations should not be ignored
-
Repository
(from [363545aa20014c56f6da223acc4a46de5c873143]) Different nested validations should not be ignore [#3638 Different nested validations should not be ignored status:resolved] http://github.com/rails/rails/commit/363545aa20014c56f6da223acc4a46...
-
José Valim
- State changed from open to resolved