Topic: Best way to deal with ActiveRecord::RecordNotFound
Ok. This is coming up a lot for me.
In most cases, it's not a big deal.
I just want to deal with it like a conditional:
def find (topic_type)
User.find(@user.id, :include => 'topics', :conditions => ["topics.type=?", topic_type]).topics
and then just pass it along from the controller to the view.
it knows how to deal with no results!
my_favorites = Favorite.new(session['user'])
@my_topics = my_favorites.find topic_type
render :template => 'shared/topics/favorites'
But it's not working for some reason.
In most cases now I find myself checking exists?
first, which I'd rather not do for the extra database hit.
However, it tends to work more like my thinking out the problem.
And don't even get me started on rescue_action_in_public, which
only seems to work in my application_controller, not in any
specific controllers I use...