Hi,
I’m trying to override the “redirect_to” method in the
ActionController’s Base class but I am running into some trouble. The
method seems to reside in “class Base”, “class << self”. This might be
part of the problem.
First of all I am using one file to specify all my overrides:
“overrides.rb”, which I require in my “environment.rb” file.
In any case if I try to override it like so:
class ActionController::Base
def redirect_to
# do something
end
end
It fails since it can’t find the name: ActionController. I solved this
by moving the override into the “application_helper.rb” file. Is there
a way to position my “overrides.rb” file so that it could override this
method?
When I place the override in my application_helper i can override it
but I can’t call “super”. It seems to think there is no super method
available (this might be caused by the class << self part?).
Currently I solved the problem by copying the code from “base.rb”'s
redirect_to function into the override like so.
class ActionController::Base
def redirect_to(options = {}, *parameters_for_method_reference)
#:doc:
# do something
case options
...
... # much code that should not be here :(
...
end
end
end
Needless to say this method sucks (big time). I’d like to know the
correct way to override this method.
Andre Foeken