Airbrake, Rails and Heroku

ruby flag

Setting up new Rails Project with Airbrake

Step 1: Install Rails

gem install rails
=> Successfully installed rails-x.x.x

Step 2: Create a new Rails app

Heroku apps use postgresql so be sure to add --database=postgresql when you create your Rails app.

rails new airbrake_rails_test --database=postgresql

Step 3: Add airbrake to the Gemfile and install

cd airbrake_rails_test
echo "gem 'airbrake'" >> Gemfile
bundle install

Step 4: Sign up for Airbrake and create a project

Sign up for Airbrake and create a project for your Rails app. After your Airbrake project has been created you will need it’s API_KEY and PROJECT_KEY to generate your Airbrake config.

rails generate airbrake PROJECT_ID API_KEY

If your configuration was successful and the test error was sent correctly you should see a locate link at the bottom of the output:

The test exception was sent. Find it here:

you can view your error in the Airbrake dashboard by following the locate link.

If you would like to test your Airbrake config/setup, run the following rake command from your local environment:

bundle exec rake airbrake:test

Deploying to Heroku (without the addon)

Step 1: initialize your project with git

Starting from where we left off–in the airbrake_rails_test directory from above. Make a local git repo:

git init
git add .
git commit -am "Projet Start"

Step 2: Then create the heroku app:

heroku create airbrake_rails_test

Step 3: And push your code to heroku:

git push heroku master

Step 4: Test your Airbrake setup on heroku

run this rake command to send a test exception from your heroku app:

heroku run rake airbrake:test

visit the locate link near at the bottom of the command’s output to see your error in Airbrake.