ruby-on-railsrubydevisedevise-invitable

Devise invitable change accept_invitation_url


In the invitation mail I can see method that generates acceptation link:

accept_invitation_url(@resource, invitation_token: @token)

and I'd like to know how to edit(or override) this method so I can put there my custom route. I have seen some similar threads, but most of them are outdated or don't provide any working solutions.

Can someone explain me how does it work?


Solution

  • You can customize mailer view with your own stuff

    Use this for generate devise invitable views rails generate devise_invitable:views For more information about view check this link.

    And customize app/views/devise/mailer/invitation_instruction.html.erb to get your stuff working. In this file you can change this method to <p><%= link_to 'Text Here', "YOUR_OWN_ROUTE_HERE?invitation_token=#{@token}" %></p> by doing this you can send whatever link you like and then you have to write a route as well for it which calls the default method of devise.

    UPDATE

    When you invite user it will call create action of Users::InvitationsController and you can overide the controller also, refere Customize devise invitable Controller