Ok title is confusing, Ill tell you my problem first:
the polymorphic_url
method was changed in Rails 2.2.1 to include some extra functionality I need. However, I want to make the application still work in older versions of Rails, so I wanted to patch on the 2.2.1 behaviour if an older Rails version is running.
alias_method_chain
to the rescue right? I cant get it to work.
def polymorphic_url_with_compat(*args)
whatever...
return polymorphic_url(*args)
end
alias_method_chain :polymorphic_url, :compat
Now I first tried putting this in the helper - alias_method_chain
fails because polymorphic_url
isnt defined by then.
So I moved the same code into the controller, and it doesnt error, but it gets ignored.
Then I tried patching it into ApplicationController::Base with a plugin - polymorphic_url
is still not defined.
polymorphic_url
is defined in the module ActionController::PolymorphicRoutes. I dont really know when/where it is mixed into the controller/view.
How can I wrap this method in the way i want to?