Rails Custom Deprecation Notices
In Rails 3 you can use the : "deprecate" method from ActiveSupport:
class Example def foo end deprecate :fooend
It will create an alias for your method and output a warning with a stack trace. You can also use parts of this functionality directly, e.g:
ActiveSupport::Deprecation.warn("Message")
It will output the stack trace along with the message.
Maybe:
def old_relationship warn "[DEPRECATION] old_relationship is deprecated." @old_relationshipenddef old_relationship=(object) warn "[DEPRECATION] old_relationship is deprecated." @old_relationship = objectend
Something along those lines for a relationship.
In the majority of cases, you can just raise a warning and call the new method.
class Example # <b>DEPRECATED:</b> Please use <tt>good_method</tt> instead. def bad_method warn "`bad_method` is deprecated. Use `good_method` instead." good_method end def good_method # ... endend
There are libraries or metaprogramming if you need or want to get fancier, but in general that's not a good route to go for something this simple. You should have a pretty good reason to introduce a dependency for something this simple.