I am using rails 2.3.8 . I need to call a controllers action from a initializer. I found this snippet in rails 3 usin Proc
OmniAuth.config.on_failure = Proc.new do |env|
UserSessionsController.action(:omniauth_failure).call(env)
end
If i use this in Rails 2.3.8, it returns this error
undefined method `action' for UserSessionsController:Class.
It seems Rails 2.3.8 does not have "action" method. Is there any other way to call an action from initializer in Rails 2.3.x?
I'm not sure why you would want to do this, but controllers are just classes. So something like
TestController.new.index
will call the index
method.
Keep in mind that the controller will be initialized w/o all the info that normally comes in w/ a request, so its very possible that things will break.