从GEM中调用Application Controller中的方法

发布于 2025-02-11 18:08:13 字数 865 浏览 1 评论 0原文

我有一个通过第三方处理用户身份验证的GEM,并希望通过应用程序控制器中的方法在使用Deveise的特定用户签名。

我需要传递有关从宝石到主应用程序身份验证哪个用户的信息。

当我尝试调用applicationControllers的 GEM中的altered_authentication_sign_in(@user)方法中,我得到了一个错误:

nomethoderror(未定义的方法`pountation_authentication_sign_in's'for#< em> gemname :::: classname classname ):

application_controller.rb

class ApplicationController < ActionController::Base
  ...
  def completed_authentication_sign_in(user)
    @user = user
    sign_in_and_redirect(@user)
  end
  ...
end

custom_gem.rb

module GemName
  class ClassName
    ... # authenticates and sets the @user object.
    completed_authentication_sign_in(@user)
  end
end

我已经尝试直接在宝石中调用dection device的sign_in_in_and_redirect(@user)方法它缺少相关的会话信息。

I have a Gem that handles authentication of users via a third party, and want to sign in a specific user using Devise, through a method in the Application Controller.

I need to pass information about which user has been authenticated from the gem to the main app.

When I try calling ApplicationControllers's
completed_authentication_sign_in(@user) method in the Gem, I get this error:

NoMethodError (undefined method `completed_authentication_sign_in' for #<GemName::ClassName:0x000055ab8839ef70>):

application_controller.rb

class ApplicationController < ActionController::Base
  ...
  def completed_authentication_sign_in(user)
    @user = user
    sign_in_and_redirect(@user)
  end
  ...
end

custom_gem.rb

module GemName
  class ClassName
    ... # authenticates and sets the @user object.
    completed_authentication_sign_in(@user)
  end
end

I've tried calling Device's sign_in_and_redirect(@user) method directly in the Gem, but that doesn't work as it's missing relevant session information.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文