Use proc in validation

In the ruby ​​on the guide rails there is a section 5.3 Using Proc with: if and: if discussed Using Proc with: if and: if in the check helper. He gives the following example:

class Account < ActiveRecord::Base validates_confirmation_of :password, :unless => Proc.new { |a| a.password.blank? } end 

Does this parameter a in Proc refer to the current instance of the account? Can I understand this ("a") as a reference to the current instance of the account?

- dot :password and a.password in the same?

+4
source share
1 answer

That is exactly what it is. a refers to the object being scanned.

+9
source

Source: https://habr.com/ru/post/1338821/


All Articles