The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
How to Turn Deprecation Warnings Off in Rails

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
rwdaigle

Posts: 312
Nickname: rwdaigle
Registered: Feb, 2003

Ryan is a passionate ruby developer with a strong Java background.
How to Turn Deprecation Warnings Off in Rails Posted: Dec 4, 2006 8:18 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by rwdaigle.
Original Post: How to Turn Deprecation Warnings Off in Rails
Feed Title: Ryan's Scraps
Feed URL: http://feeds.feedburner.com/RyansScraps
Feed Description: Ryan Daigle's various technically inclined rants along w/ the "What's new in Edge Rails" series.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by rwdaigle
Latest Posts From Ryan's Scraps

Advertisement

I was talking with a friend of mine last week about the new Rails deprecation warnings that you’ll see when you do naughty things like access @cookies from your controller or use deprecated methods like ActiveRecord’s find_all. Sometimes it’s useful to turn off those warnings – especially when they’re coming from a part of your application you don’t control (i.e. a third-party library).

To turn off all deprecation warnings, just do the following:

ActiveSupport::Deprecation.silenced = true

Or, if you want to perform something other than spit out deprecation warnings you can re-route them however you want within a block:

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

Or, if you want to be more granular, you can silence specific parts of your code that you know reference deprecated code:

def bad_action
  ActiveSupport::Deprecation.silence { p "Referencing #{@cookies} is bad" }
end

Hopefully this will get you past any annoying deprecations you can’t do much about (without giving you an easy out for those that you can do something about).

Read: How to Turn Deprecation Warnings Off in Rails

Topic: Under the hood: ActiveRecord::Base.find, Part 3 Previous Topic   Next Topic Topic: When the GC is doing its job, but your app still needs too much RAM

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use