【问题标题】:undefined method `action' for a Controller控制器的未定义方法“动作”
【发布时间】:2013-10-04 11:46:43
【问题描述】:

我在我的网络应用程序中使用了omniauth。我正在尝试捕获omniauth 失败(权限被拒绝错误)异常。我提到了这篇文章。 How to rescue OmniAuth::Strategies::OAuth2::CallbackError?

我的初始化程序中有这段代码。

  OmniAuth.config.on_failure = Proc.new do |env|
  UserSessionsController.action(:omniauth_failure).call(env)
  end

我收到此错误:

  undefined method `action' for UserSessionsController:Class

谁能帮帮我?我正在使用 ruby​​ 1.8.7 和 rails 2.3.8

【问题讨论】:

  • 您所指的帖子是关于 RoR 3 应用程序,而您正在处理 RoR 2 应用程序。我想这就是问题所在。
  • 有没有办法在 RoR2 中实现这个功能?
  • OmniAuth 似乎没有设计用于 Rails 2.3.x (stackoverflow.com/questions/6686780/…) 的版本。

标签: ruby-on-rails ruby oauth-2.0 omniauth


【解决方案1】:
OmniAuth.config.on_failure = Proc.new do |env|
  # https://github.com/intridea/omniauth/blob/d02f9d58f70f132c856199470f94b93c852d9bb0/lib/omniauth/failure_endpoint.rb
  # line no 29,30,31
end

【讨论】:

    猜你喜欢
    • 2011-06-16
    • 1970-01-01
    • 1970-01-01
    • 2018-01-12
    • 1970-01-01
    • 2022-11-05
    • 2018-06-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多