Take the 2-minute tour ×

Can anyone tell me how to silence deprecation warinings in Rails 3?

I have a few situations where it is throwing false positives. Namely using - for loops in haml and f.error_messages from the dynamic_form plugin.


share|improve this question
Do you want to silence all deprecation warnings or just warnings in selected blocks of code? –  mikej Apr 22 '10 at 9:52
preferably just the pieces of code i know are safe, but either way if i could toggle it would be nice just to cut out some log noise. –  sfusion Apr 22 '10 at 12:46

3 Answers 3

up vote 39 down vote accepted

To silence all deprecation warnings you can do:

ActiveSupport::Deprecation.silenced = true

This could be placed in an initializer or in the environment file for a specific environment (e.g. to silence only in production for example.)

Or for a specific section of code, enclose it in a block:

ActiveSupport::Deprecation.silence do
  # no warnings for any use of deprecated methods here
share|improve this answer
both work a treat, thank you :) –  sfusion Apr 22 '10 at 13:44
I also have some great black duct tape you can put over your engine oil light ;) –  Michael Durrant Dec 19 '13 at 1:22

The accepted answer didn't work for me with Rails 3.2.12. Placing it in either the environments/production.rb or an initializer still outputted the warnings. I had to put it in my config/environment.rb file before the application was initialized:

# Load the rails application
require File.expand_path('../application', __FILE__)

::ActiveSupport::Deprecation.silenced = true if Rails.env.production?

# Initialize the rails application
share|improve this answer
thank you for posting, compared to the other solutions, this is the only thing that worked in Rails 4 –  chrishough Mar 13 at 18:40

Ryan Daigle wrote an article about this, in which he also showed how you can intercept the deprecation warning and do something else with it, like send it to a log file:

ActiveSupport::Deprecation.behavior = Proc.new { |msg, stack| MyLogger.warn(msg) }


share|improve this answer

Your Answer


