Rails 3: Render Production Errors in 1 Controller

We want to see errors in production only for our admin controllers.
In Rails 2 this was simple, but now we had to get hacky:

class AdminController < ApplicationController
  rescue_from Exception, :with => :render_simple_error if Rails.env.production?
  def render_simple_error(e)
    render :text => "#{e.message} -- #{e.class}<br/>#{e.backtrace.join("<br/>")}"
  end
end

Its not very pretty (session/params are missing), but solves our pain for now.

Advertisements

2 thoughts on “Rails 3: Render Production Errors in 1 Controller

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s