Documentation for active record "validates" helper


I am following the 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 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”)

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

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?


sorry the code i posted was for rails 2.3.x

watch this

Greg Donald |

Thank you Greg!