I have an application I\'m writing where I\'m allowing the administrators to add aliases for pages, categories, etc, and I would like to use a different controller/action depend
I'm not sure I fully understand the question, but you could use method_missing
in your controllers and then lookup the alias, maybe like this:
class MyController
def method_missing(sym, *args)
aliased = Alias.find_by_action_name(sym)
# sanity check here in case no alias
self.send( aliased.real_action_name )
# sanity check here in case the real action calls a different render explicitly
render :action => aliased.real_action_name
end
def normal_action
@thing = Things.find(params[:id])
end
end
If you wanted to optimize that, you could put a define_method
in the method_missing
, so it would only be 'missing' on the first invocation, and would be a normal method from then on.