This project is archived and is in readonly mode.
_validators works on ActiveRecord::Base instead of individual models
-
TMaYaD
Something really funny is going on here.
$ rails c Loading development environment (Rails 3.0.0.beta4) ruby-1.9.2-rc2 > Ingredient.validators_on(:name) => [] ruby-1.9.2-rc2 > Product.validators_on(:name) => [#<ActiveModel::Validations::PresenceValidator:0x00000002094118 @attributes=[:name], @options={}>] ruby-1.9.2-rc2 > Ingredient.validators_on(:name) => [#<ActiveModel::Validations::PresenceValidator:0x00000002094118 @attributes=[:name], @options={}>] -
TMaYaD
- Assigned user set to José Valim
- Tag changed from nested_attributes_for, reflection, validation, validations to reflection, validation, validations
Probing further it seems this behavior is universal and not limited to nested attributes
The validations keep piling up to the previously queried onesIn the diff for the commit that added this feature ( http://github.com/rails/rails/commit/8f97e9d19abf02b33c5f7c0c1f1d5d... ) self refers to ActiveResource::Base or ActiveRecord::Base but not the model itself as expected.
Assigning to Jose Valim as he is likely to have more insight into this.
-
TMaYaD
- Title changed from Validators_on an attribute of nested model returns validatations on attribute with same name from parent model to _validators works on ActiveRecord::Base instead of individual models
-
TMaYaD
This fixes it
http://github.com/TMaYaD/rails/commit/8a7e5bd076833d55819102919e453...May need refactoring and definitely needs tests
-
José Valim
- State changed from new to resolved
- Importance changed from to Low
I believe this is fixed in RC.