exceptions

Rails 3: Customized exception handling

Exceptions happen. There’s no way around that. But not all exceptions are created equally. For instance, a 404 “Not found” error can (and should) be handled correctly in your application. Let me give you an example of how to handle a ActiveRecord::RecordNotFound exception. Let’s assume you have an application that could show a user profile: # GET /p/:name def show @profile = Profile.find(params[:name]) end Now, it may happen that the :name paramater contains a value that cannot be found in our database, most likely because someone made a typo in the URL.