# Rails 2.0 error ActiveRecord handling/reporting best practice

**URL:** <https://www.ruby-forum.com/t/rails-2-0-error-activerecord-handling-reporting-best-practice/127251>\
**Category:** Rails\
**Created:** [January 27, 2008, 2:33am UTC](https://www.ruby-forum.com/t/rails-2-0-error-activerecord-handling-reporting-best-practice/127251 "2008-01-27T02:33:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![acampos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/919ad9/32.png) [@acampos](https://www.ruby-forum.com/u/acampos)\
**Post date:** [January 27, 2008, 2:33am UTC](https://www.ruby-forum.com/t/rails-2-0-error-activerecord-handling-reporting-best-practice/127251/1 "2008-01-27T02:33:44Z")

</div>

I’ve included

rescue\_from ActiveRecord::RecordNotFound

in my application.rb file in order to catch and report all failed  
ActiveRecord find operations. However, ActiveRecord does not raise  
this exception from the dynamic finders that it includes in models.  
So is the best practice to avoid use of the dynamic finders and only  
use find() instead? Or is it common to make use of the dynamic  
finders and have my controller raise ActiveRecord::RecordNotFound when  
a dynamic finder returns nil? Just curious how others typically  
handle this sort of thing.

---

<div class="post-metadata">

**Author:** ![acampos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/919ad9/32.png) [@acampos](https://www.ruby-forum.com/u/acampos)\
**Post date:** [January 27, 2008, 3:02am UTC](https://www.ruby-forum.com/t/rails-2-0-error-activerecord-handling-reporting-best-practice/127251/2 "2008-01-27T03:02:38Z")

</div>

you can do it to thrown an exception: self.find\_by\_id(id) ||  
ActiveRecord::RecordNotFound  
and you can also read this discution which is really interesting about  
the topic :  
[http://groups.google.com/group/rubyonrails-core/browse\_thread/thread/9b79f15be8cea7ab/465c7b2f24b03363](http://groups.google.com/group/rubyonrails-core/browse_thread/thread/9b79f15be8cea7ab/465c7b2f24b03363)
