我正在尝试将一些代码从我的 Controller 移到一个服务对象中。如何从服务对象访问设计 sign_in 帮助程序方法。
class CompleteAccountRegistration
def self.call(account_id, plan_id)
@account = Account.find(account_id)
self.create_user_account
self.create_subscription(plan_id)
sign_in(User.find(@account.owner_id))
end
我在测试中遇到以下错误。
NoMethodError:
undefined method `sign_in' for CompleteAccountRegistration:Class
最佳答案
包括Devise::Controllers::SignInOut
在您的服务对象中起作用!
关于ruby-on-rails - 如何访问服务对象中的设备登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27219191/