How-To: Heroku + Hoptoad

Hoptoad is a great service by Thoughtbot for collecting exceptions. Like exception_notifier, but without clogging your inbox, and much prettier.

Using Hoptoad with Heroku is a cinch. First, sign up for a free Hoptoad account.

Now install their notifier plugin. If you’re working locally and deploying to Heroku with Git, install with script/plugin:

script/plugin install git://github.com/thoughtbot/hoptoad_notifier.git

Or if you’re using the Heroku web editor, open the vendor folder and click Gems & Plugins, then enter the plugin URL in the “Install from URL” box at the bottom.

Next, create a new file config/initializers/hoptoad.rb containing:

HoptoadNotifier.configure do |config|
  config.api_key = 'your_key_here'
end

Paste in the API key provided for your account in place of your_key_here.

Last, add this line to your app/controllers/application.rb:

  include HoptoadNotifier::Catcher

To test, create a page that throws an exception:

class CrashController < ApplicationController
        def index
                raise "boom"
        end
end

If you’re in the web editor you can navigate straight to your app. If you’re working locally, commit and push to Heroku:

git add .
git commit -m 'use hoptoad for exception notifications'
git push

Now hit http://yourapp.heroku.com/crash to generate an exception. Flip over to your Hoptoad account, and you should see your CrashController exception in all its Hoptoad splendor!

Tags: howto

Browse the blog archives or subscribe to the full-text feed.