How to access devise sign_in in a service object

I am trying to move some code from my controller and to a service object. How can I access the helper method sign_in from a 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

In my tests, the following error appears.

 NoMethodError:
   undefined method `sign_in' for CompleteAccountRegistration:Class
+4
source share
1 answer

Inclusion of service Devise::Controllers::SignInOutinto your facility does the trick!

0
source

All Articles