# How to give back the hand to AR error handling?

**URL:** <https://www.ruby-forum.com/t/how-to-give-back-the-hand-to-ar-error-handling/153556>\
**Category:** Rails\
**Created:** [November 18, 2008, 7:18pm UTC](https://www.ruby-forum.com/t/how-to-give-back-the-hand-to-ar-error-handling/153556 "2008-11-18T19:18:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![itkin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/22d042/32.png) [@itkin](https://www.ruby-forum.com/u/itkin)\
**Post date:** [November 18, 2008, 7:18pm UTC](https://www.ruby-forum.com/t/how-to-give-back-the-hand-to-ar-error-handling/153556/1 "2008-11-18T19:18:15Z")

</div>

In controller I use to raise some specific error as follows :

include CustomErrors

rescue\_from NoGuestFound,NoHostFound,NoInvitation,WrongPass do |e|  
flash[:message] = e.message  
redirect\_to :action =\> :index  
end

def lambda  
…  
@guest.is\_invited\_by?(@host) or raise CustomError1.new ‘context  
message’  
…  
end

I find this way of doing pretty OK, but for AR model validation I’d like  
to give back the end to the Active Record standard validation process. I  
can’t find good doc on how to do so and how AR validation works  
exactly…

if anybody has a better way to deal with error handling or if you could  
give me some smart links, would appreciate !
