This project is archived and is in readonly mode.

#4821 ✓resolved
Evgeniy Dolzhenko

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

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

person = => 'zoolander')
person.valid?          #=> false

which won't work and I believe the end should read like

person =
person.first_name = 'zoolander'
person.valid?          #=> false

Comments and changes to this ticket

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=""></a>