# Documentation for active record "validates" helper

**URL:** <https://www.ruby-forum.com/t/documentation-for-active-record-validates-helper/195029>\
**Category:** Rails\
**Created:** [September 15, 2010, 3:07pm UTC](https://www.ruby-forum.com/t/documentation-for-active-record-validates-helper/195029 "2010-09-15T15:07:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_LidstrSSSSm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a9a28c/32.png) [@Daniel\_LidstrSSSSm](https://www.ruby-forum.com/u/Daniel_LidstrSSSSm)\
**Post date:** [September 15, 2010, 3:07pm UTC](https://www.ruby-forum.com/t/documentation-for-active-record-validates-helper/195029/1 "2010-09-15T15:07:52Z")

</div>

Hello,

I am following the [railstutorial.org](http://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](http://github.com/dlidstrom/bowling/blob/master/app/models/user.rb)  
[2]  
[http://guides.rubyonrails.org/active\_record\_validations\_callbacks.html](http://guides.rubyonrails.org/active_record_validations_callbacks.html)

---

<div class="post-metadata">

**Author:** ![Daniel\_LidstrSSSSm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a9a28c/32.png) [@Daniel\_LidstrSSSSm](https://www.ruby-forum.com/u/Daniel_LidstrSSSSm)\
**Post date:** [September 16, 2010, 1:34pm UTC](https://www.ruby-forum.com/t/documentation-for-active-record-validates-helper/195029/2 "2010-09-16T13:34:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Daniel\_LidstrSSSSm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a9a28c/32.png) [@Daniel\_LidstrSSSSm](https://www.ruby-forum.com/u/Daniel_LidstrSSSSm)\
**Post date:** [September 17, 2010, 4:51pm UTC](https://www.ruby-forum.com/t/documentation-for-active-record-validates-helper/195029/3 "2010-09-17T16:51:31Z")

</div>

On Fri, Sep 17, 2010 at 9:46 AM, Daniel Lidström [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> 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?

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

–  
Greg D.  
[destiney.com](http://destiney.com) | [gregdonald.com](http://gregdonald.com)

---

<div class="post-metadata">

**Author:** ![Daniel\_LidstrSSSSm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a9a28c/32.png) [@Daniel\_LidstrSSSSm](https://www.ruby-forum.com/u/Daniel_LidstrSSSSm)\
**Post date:** [September 17, 2010, 4:47pm UTC](https://www.ruby-forum.com/t/documentation-for-active-record-validates-helper/195029/4 "2010-09-17T16:47:25Z")

</div>

On 16 Sep, 13:34, radhames brito [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 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

---

<div class="post-metadata">

**Author:** ![Daniel\_LidstrSSSSm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a9a28c/32.png) [@Daniel\_LidstrSSSSm](https://www.ruby-forum.com/u/Daniel_LidstrSSSSm)\
**Post date:** [September 17, 2010, 5:04pm UTC](https://www.ruby-forum.com/t/documentation-for-active-record-validates-helper/195029/5 "2010-09-17T17:04:24Z")

</div>

watch this

> **[\#211 Validations in Rails 3 - RailsCasts](http://railscasts.com/episodes/211-validations-in-rails-3)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.

---

<div class="post-metadata">

**Author:** ![Daniel\_LidstrSSSSm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a9a28c/32.png) [@Daniel\_LidstrSSSSm](https://www.ruby-forum.com/u/Daniel_LidstrSSSSm)\
**Post date:** [September 19, 2010, 5:19pm UTC](https://www.ruby-forum.com/t/documentation-for-active-record-validates-helper/195029/6 "2010-09-19T17:19:13Z")

</div>

> [http://www.railsapi.com/doc/rails-v3.0.0/classes/ActiveModel/Validati](http://www.railsapi.com/doc/rails-v3.0.0/classes/ActiveModel/Validati)…
> 
> –  
> Greg D.  
> [destiney.com](http://destiney.com) | [gregdonald.com](http://gregdonald.com)

Thank you Greg!

Daniel

---

<div class="post-metadata">

**Author:** ![Daniel\_LidstrSSSSm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a9a28c/32.png) [@Daniel\_LidstrSSSSm](https://www.ruby-forum.com/u/Daniel_LidstrSSSSm)\
**Post date:** [September 17, 2010, 5:03pm UTC](https://www.ruby-forum.com/t/documentation-for-active-record-validates-helper/195029/7 "2010-09-17T17:03:13Z")

</div>

sorry the code i posted was for rails 2.3.x
