Installing Airbrake in a Rails Application.

Rails Installation

Rails 4.x & 3.x

Add the airbrake gem to your Gemfile. In Gemfile:

gem 'airbrake'

In your project's RAILS_ROOT, and in your development environment, run:

bundle install
rails generate airbrake --api-key your_project_key_here

The generator creates a file under config/initializers/airbrake.rb configuring Airbrake with your API key. This file should be checked into your version control system so that it is deployed to your staging and production environments.

Rails 2.x

Add the airbrake gem to your app. In config/environment.rb:

config.gem 'airbrake'
or if you are using bundler:
gem 'airbrake', :require => 'airbrake/rails'
Then from your project's RAILS_ROOT, and in your development environment, run:
rake gems:install
rake gems:unpack GEM=airbrake
script/generate airbrake --api-key your_key_here
As always, if you choose not to vendor the airbrake gem, make sure every server you deploy to has the gem installed or your application won't start.

The generator creates a file under config/initializers/airbrake.rb configuring Airbrake with your API key. This file should be checked into your version control system so that it is deployed to your staging and production environments.

Ignored Rails Exceptions

Exceptions raised from Rails environments named development, test or cucumber will be ignored by default.

You can clear the list of ignored environments with this setting:

config.development_environments = []
List of ignored exception classes includes:
ActiveRecord::RecordNotFound
ActionController::RoutingError
ActionController::InvalidAuthenticityToken
CGI::Session::CookieStore::TamperedWithCookie
ActionController::UnknownHttpMethod
ActionController::UnknownAction
AbstractController::ActionNotFound
Mongoid::Errors::DocumentNotFound
You can alter this list with
config.ignore_only = []
which will cause none of the exception classes to be ignored.

RunetimeError in dev/staging

To report upon 500 errors in environments other than production you have to adjust 2 things:

  1. add the following line in config/initializers/airbrake.rb

    config.development_environments = [] 
    // Reports on all environments
    
  2. In config/environments/development.rb change config.consider_all_requests_local from true to false

    config.consider_all_requests_local = false 
    // Shows prod style errors
    

Legacy Issues

Rails 2.3 + Ruby 1.8.7

Error:

undefined local variable or method `configuration_output'

The Airbrake gem has two "airbrake_generator.rb" files.

You must copy the definitions "secure?", "test_mode?", and "configuration_output"

FROM: APP_ROOT/vendor/gems/airbrake-3.1.14/lib/rails/generators/airbrake/airbrake_generator.rb

INTO: APP_ROOT/vendor/gems/airbrake-3.1.14/generators/airbrake/airbrake_generator.rb

This should resolve the error and allow you to see notices in your control panel.

Supercharge Airbrake on Rails

How-to's

Here's the complete list of all guides:
* Customizing airbrake.rb