I would like to validate attributes in a function like this
class User < ActiveRecord::Base
validate :check_name( :name )
def check_name( name )
... if name is invalid ...
self.errors.add( :name, 'Name is invalid')
end
end
Can you please write the right code? Please explain the functionality why... THX!