This project is archived and is in readonly mode.
Validator defined with validates_each doesn't receive attr value on model creation
Reported by Evgeniy Dolzhenko | June 10th, 2010 @ 02:43 PM
Sorry for confusion, title of the ticket says the wrong thing, I removed non-relevant information from the ticket, it turned out to be just a minor docs mistake
here
http://github.com/rails/rails/commit/a07d0f87863e01ef931c87bd35bd36...
there is example of using ActiveModel::Validations
class Person
include ActiveModel::Validations
attr_accessor :first_name, :last_name
validates_each :first_name, :last_name do |record, attr, value|
record.errors.add attr, 'starts with z.' if value.to_s[0] == ?z
end
end
person = Person.new(:first_name => 'zoolander')
person.valid? #=> false
which won't work and I believe the end should read like
person = Person.new
person.first_name = 'zoolander'
person.valid? #=> false
Comments and changes to this ticket
-
Neeraj Singh June 10th, 2010 @ 03:09 PM
Good catch.
Please clone http://github.com/lifo/docrails, update the doc and push the changes.
-
DHH June 10th, 2010 @ 04:59 PM
- State changed from new to resolved
-
Evgeniy Dolzhenko June 15th, 2010 @ 09:10 AM
Pushed fixes from the patch to docrails http://github.com/lifo/docrails/commit/ed507300f05fa5e86f7f7d8988f2...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>