Stop registration mail while sending invitation mail in ruby

164 Views Asked by At

In my application confirmation mail is sent after the entry goes in User's table or new user signs up. But in my application I am also using devise invitable. In that when I do User.invite then the invitation is sent but since the entry also goes in users table the confirmation mail is also sent. But can I stop the confirmation mails being sent while sending the invitation to users. I had added skip_confirmation: truewhile adding the invitation but still the confirmation mails are sent. Can someone suggest some solution for this?

1

There are 1 best solutions below

0
mxs On

I did this (and a few other modifications) by altering the devise_invitable controller action for create. The README has a section called "Configuring Controllers" to get you started down this road.

You want to follow the instructions in that section to create a new controller that inherits from Devise::InvitationsController. In the newly-created controller include a create method that uses the skip_confirmation! method and then super (refer) to the parent controller to finish the action.

This is untested code, but you'd have something like:

class Users::InvitationsController < Devise::InvitationsController
  def create
      resource.skip_confirmation!    
      super
  end
end

When I was figuring out how to modify the default Devise_Invitable behavior, I found looking at the source controller really helpful - here it is.