0

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?

4

1 回答 1

1

我不确定您为什么要这样做,但控制器只是类。所以像

TestController.new.index

将调用该index方法。

请记住,控制器将被初始化而没有通常在请求中出现的所有信息,因此事情很可能会中断。

于 2013-10-07T22:13:26.460 回答