Create action with delayed_job <p>In my controller I am trying to move my create method into a background process, as it takes too much time. I can't get it right. </p> <p>My option 1:</p> <p>First I went with creating a self method for my controller so it looked like this:</p> <pre><code> def create MyController.delay.create_and_email(current_app_user) respond_to do |format| format.js {} end end def create_and_email(user) @user = AppUser.find_by(id: user.id) @link_share = @user.link_shares.build(link_share_params) @link_share.save end </code></pre> <p>I had to throw in the current_app_user as the self method could not see it, but I got totally puzzled on what to do with my link_share strong params, because the self method does not see the <strong>link_share_params</strong>. I guess I could make this option work, if anyone would point me how to throw in strong params into a self. controller method.</p> <p>My option 2:</p> <p>I then decided to move the whole action into my User model like this</p> <p>Contoller:</p> <pre><code> def create @user = current_app_user @user.delay.create_and_email(link_share_params) respond_to do |format| format.js {} end end </code></pre> <p>Model:</p> <pre><code> def create_and_email link_share = self.link_shares.build(**params**) link_share.save end </code></pre> <p>Again, trouble with the strong params. How would I go with importing my params into the model? Should I just chain them as arguments? </p> <p>Any advice appreciated</p>