简体   繁体   中英

How to access devise sign_in in a service object

I am trying to move some code out of my controller and into a service object. How do I access the devise sign_in helper method from the service object.

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

I am getting the following error in my tests.

 NoMethodError:
   undefined method `sign_in' for CompleteAccountRegistration:Class

在服务对象中包含Devise::Controllers::SignInOut就可以了!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM