如何在服务对象中访问devise sign_in

时间:2014-11-30 22:47:05

标签: ruby-on-rails devise

我正在尝试将一些代码从我的控制器中移出并转移到服务对象中。如何从服务对象访问devise sign_in helper方法。

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

1 个答案:

答案 0 :(得分:0)

在您的服务对象中加入Devise::Controllers::SignInOut可以解决问题!