Documentation for active record "validates" helper

Hello,

I am following the railstutorial.org. The model User that is being developed [1] is using an active record "validates" helper that I want to know more about. However, when I search [2] I can't seem to find any reference to this helper. I was under the impression that "validates" is the new way (rails 3) while the helpers documented in [2] were the old method. Is this correct? Where can I read more about "validates"?

Daniel

[1] http://github.com/dlidstrom/bowling/blob/master/app/models/user.rb [2] http://guides.rubyonrails.org/active_record_validations_callbacks.html

validates triggers when validation accurds but it does not perform validation by it sellf you have to pass it the validation function

validates :to_many_drinks

def to_many_drinks self.drinks > 80 errors.add(:drinks, “LOL”) end

this add errors to the drinks column with a “LOL” message

I am not sure this is correct. This is what I am doing within my model:

validates :name, :presence => true,                     :length => { :maximum => 50 }

The above validates the name attribute, makes sure it is present and of maximu 50 characters. Both presence and length were provided by ActiveRecord (I belive), certainly not by me. But my real question is: where is this documented?

Daniel

http://www.railsapi.com/doc/rails-v3.0.0/classes/ActiveModel/Validations/ClassMethods.html#M003721

sorry the code i posted was for rails 2.3.x

watch this

http://railscasts.com/episodes/211-validations-in-rails-3

http://www.railsapi.com/doc/rails-v3.0.0/classes/ActiveModel/Validati

-- Greg Donald destiney.com | gregdonald.com

Thank you Greg!

Daniel