Rails alias_method_chain

Today I wrote a plugin for Redmine and ended up using alias_method_chain.

Its a very handy little method! What does do? It allows for convenient overrides of methods built-in to a Ruby on Rails application.

Its syntax sugar, really. This:

alias_method_chain :mymethod, :origmethod

simply encapsulates these two calls:

alias_method :mymethod_without_origmethod, :mymethod
alias_method :mymethod, :mymethod_with_origmethod
By Albert on February 23, 2011 10:59 PM

Categories: