Search code examples
ruby-on-railsdevisedevise-invitable

Split up user creation and invitation


I have an app where the admin invites new users with devise_invitable. This works fine, but I want to split things up. First I want to create the user and then later on I want to be able to invite them. How can I split up these actions?


Solution

  • You can use the skip_invitation option when using invite! to skip sending the actual invitation.

    User.invite!(:email => "[email protected]", :name => "John Doe", :skip_invitation => true)
    # the record will be created, but the invitation email will not be sent
    

    You can then send the invitation by:

    user = User.find(42)
    user.deliver_invitation
    

    https://github.com/scambra/devise_invitable