Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How prevent rollbar from reporting errors in the development environment?

How I can disable the rollbar gem from reporting errors in my development environment? I want to get errors only from staging and production, but I didn't find it in docs on Rollbar's site.

like image 566
piton4eg Avatar asked Oct 29 '13 11:10

piton4eg


4 Answers

Put this code into initializers/rollbar.rb:

Rollbar.configure do |config|
  # ...

  unless Rails.env.production?
    config.enabled = false
  end

  # ...
end
like image 173
piton4eg Avatar answered Nov 05 '22 16:11

piton4eg


I changed the following in config/initializers/rollbar.rb:

  # Here we'll disable in 'test':
  if Rails.env.test?
    config.enabled = false
  end

to

  # Here we'll disable in 'test' and 'development':
  if Rails.env.test? || Rails.env.development?
    config.enabled = false
  end
like image 22
iheggie Avatar answered Nov 05 '22 15:11

iheggie


Don't use an if (or unless) statement just to set a boolean. Also, you probably want Rollbar enabled in staging in case you need it.

Rollbar.configure do |config|

  config.enabled = Rails.env.production? || Rails.env.staging?

end
like image 11
Tim Scott Avatar answered Nov 05 '22 16:11

Tim Scott


I believe the following better answers the question:

if Rails.env.development?
  config.enabled = false
end

This code should be written in config/initializers/rollbar.rb

like image 2
robskrob Avatar answered Nov 05 '22 17:11

robskrob