Ruby on Rails: Treat deprecation warnings as errors or otherwise find deprecated code?

后端 未结 1 705
感动是毒
感动是毒 2021-02-20 07:24

I recently upgraded from Rails 2 to Rails 3, and I\'m trying to root out all the code I might have that is deprecated. The way I\'m doing this is just surfing around a copy of m

1条回答
  •  情书的邮戳
    2021-02-20 08:12

    You can customise the behaviour of deprecated calls by setting ActiveSupport::Deprecation.behavior. This should be set to a Proc that accepts a message and a callstack e.g. you could do:

    ActiveSupport::Deprecation.behavior = Proc.new { |message, callstack|
      raise message + "\n" + callstack.join("\n  ")
    }
    

    If you have automated tests for your app these are invaluable when upgrading the version of Rails being used.

    0 讨论(0)
提交回复
热议问题