# File activerecord/lib/active_record/validations.rb, line 327 327: def validate(*methods, &block) 328: methods << block if block_given? 329: write_inheritable_set(:validate, methods) 330: end
there is an example: class Comment < ActiveRecord::Base validate do |comment| comment.must_be_friends end
def must_be_friends errors.add_to_base("Must be friends to leave a comment") unless commenter.friend_of?(commentee) end end Understand how this matter?