views:

118

answers:

1

Hi,

I want to prevent users from signing up with a password = login for security reasons. I tried something like this:

  validates_each :password do |record, attr, value|
    if(value == self.login)
      record.errors.add(attr)
    end
  end

But I always get the following error: undefined method login for self. It has something to do with the class hierachy I guess, but how do I access a higher level.

I'm a little stuck here, please help.

+4  A: 

Try

if value == record.login

the record is passed into the block as the record local variable, and in this context is not self.

Squeegy
Very simple... Very nice, thanks!
ole_berlin