method

validate

validate(*methods, &block)
public

No documentation available.

# File activerecord/lib/active_record/validations.rb, line 239
      def validate(*methods, &block)
        methods << block if block_given?
        write_inheritable_set(:validate, methods)
      end

2Notes

You can call several times

szeryf · May 31, 20092 thanks

You can call it several times, like:

class Comment < ActiveRecord::Base
validate :must_be_friends
validate :must_be_awesome
...

or with several arguments:

class Comment < ActiveRecord::Base
validate :must_be_friends, :must_be_awesome
...

You can call it with an { :on => ~~~ } as the last argument

larry333 · Feb 17, 20112 thanks

For example: validate :must_be_friends, :on => :create