Rails

In Rails, all uncaught exceptions will be automatically reported.

We support Rails 4 and newer.

Install

Add the sentry-ruby gem to your Gemfile:

Gemfile
Copied
gem "sentry-raven"

Configure

Initialize the SDK within your config/application.rb:

config/application.rb
Copied
Raven.configure do |config|
  config.dsn = 'https://examplePublicKey@o0.ingest.sentry.io/0'
end

If you have added items to Rails’ log filtering, you can also make sure that those items are not sent to Sentry:

Copied
# in your application.rb:
config.filter_parameters << :password

# in an initializer, like sentry.rb
Raven.configure do |config|
  config.dsn = 'https://examplePublicKey@o0.ingest.sentry.io/0'

  config.sanitize_fields = Rails.application.config.filter_parameters.map(&:to_s)
end

Verify

The platform or SDK you've selected either does not support this functionality, or it is missing from documentation.

If you think this is an error, feel free to let us know on GitHub.

Additional Notes

Params and sessions

Copied
class ApplicationController < ActionController::Base
  before_action :set_raven_context

  private

  def set_raven_context
    Raven.user_context(id: session[:current_user_id]) # or anything else in session
    Raven.extra_context(params: params.to_unsafe_h, url: request.url)
  end
end

Caveats

Currently, custom exception applications (config.exceptions_app) are not supported. If you are using a custom exception app, you must manually integrate Raven yourself.

You can edit this page on GitHub.