从GEM中调用Application Controller中的方法
我有一个通过第三方处理用户身份验证的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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论