# ActiveRecord::Errors best practices?

**URL:** <https://www.ruby-forum.com/t/activerecord-errors-best-practices/166562>\
**Category:** Rails\
**Created:** [April 27, 2009, 1:05pm UTC](https://www.ruby-forum.com/t/activerecord-errors-best-practices/166562 "2009-04-27T13:05:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![joachimgross](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/258eb7/32.png) [@joachimgross](https://www.ruby-forum.com/u/joachimgross)\
**Post date:** [April 27, 2009, 1:05pm UTC](https://www.ruby-forum.com/t/activerecord-errors-best-practices/166562/1 "2009-04-27T13:05:16Z")

</div>

I’m currently reviewing some old code from Rails 1.x times and found  
this:

ActiveRecord::Errors.default\_error\_messages = {  
:inclusion =\> “inclusion|”,  
:exclusion =\> “exclusion|”,  
:invalid =\> “invalid|”,  
:confirmation =\> “confirmation|”,  
:accepted =\> “accepted|”,  
:empty =\> “empty|”,  
:too\_long =\> “too\_long|”,  
:too\_short =\> “too\_short|”,  
:wrong\_length =\> “wrong\_length|”,  
:taken =\> “taken|”,  
:not\_a\_number =\> “not\_a\_number|”,  
}

Used on controller code to check if a specific error happens, like this:

if @user.errors.on(“email”).to\_s.include? “taken|”  
…  
end

Are there better practices for doing this?
