alias-method-chain

Overring a Rails core mixin method, and still being able to call the old method

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 th...

Rails - alias_method_chain with a 'attribute=' method

Hi there, I'd like to 'add on' some code on a model's method via a module, when it is included. I think I should use alias_method_chain, but I don't know how to use it, since my 'aliased method' is one of those methods ending on the '=' sign: class MyModel < ActiveRecord::Base def foo=(value) ... do stuff with value end end ...

alias_attribute and creating and method with the original attribute name causes a loop

Im trying to dynamically create a method chain in one attribute in my model. By now I have this function: def create_filtered_attribute(attribute_name) alias_attribute "#{attribute_name}_without_filter", attribute_name define_method "#{attribute_name}" do filter_words(self.send("#{attribute_name}_without...

Alias method chain in ruby calling itself

I am rewriting the controller render method, however, I want to use the old method when in the render_to_string method. These are my current codes: def render_with_xhr(options = {}, extra_options = {}, xhr_check = true, &block) if xhr_check && request.xhr? template = render_to_string(options) render_without_xhr(:update) {|page...