In my own classes I am attempting to override some of these methods. So
i do this:
module CustomRouting
def native_plugin_method
#successfully invoked
...a bunch of code
super #will call method from SubdomainRoutes::UrlWriter
end
def rewrite_with_subdomains
#method is never invoked
...code
super
end
The method created with alias_method_chain is never affected! My code
successfully overrides ‘native_plugin_method’, but it seems to do
nothing with rewrite_with_subdomains, even though everything is
identical.
Is there something about aliased methods that does not resolve in the
same way as standard methods?
You’ll have to do your own alias method chaining when you include your
module (in newer versions of rails alias_method_chain has falled out of
favour)
Fred
That’s exactly what it was! I had to re-alias the method names.
So the original plugin used alias_method_chain to alias :rewrite,
:rewrite_with_subdomain
I had to restructure my module like this:
module CustomRouting
def included(base)
base.send :alias_method, :rewrite, :rewrite_with_subdomains
end
def native_plugin_method
#successfully invoked
...a bunch of code
super #will call method from SubdomainRoutes::UrlWriter
end
def rewrite_with_subdomains
#method is never invoked
...code
super
end
end
And now my overloaded method is correctly invoked, and the ‘super’ call
works properly and invokes the previous alias.
This was really complicated. phew
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.