2
votes

I have a rails app with default devise invitations. I'd like to change the email body and the subject line, but the default mailer looks like this:

/app/views/devise/mailer/invitation_instructions.html.erb

<p><%= t("devise.mailer.invitation_instructions.hello", email: @resource.email) %></p>

<p><%= t("devise.mailer.invitation_instructions.someone_invited_you", url: root_url) %></p>

<p><%= link_to t("devise.mailer.invitation_instructions.accept"), accept_invitation_url(@resource, :invitation_token => @token) %></p>

<p><%= t("devise.mailer.invitation_instructions.ignore").html_safe %></p>

I don't see how I could edit this.

I found this resource: https://github.com/scambra/devise_invitable/wiki/Customizing-for-different-Invite-use-cases-(emails-etc.). As far as I understand it tells you how to change the subject and how to allow users to create a custom invite message.

But I don't want them to be able to create their own message. I just wanna send a system message that instead of saying "Somebody has invited you...", will dynamically insert the inviter's name like "John Smith has invited you..". I have first_name and last_name attributes in profile model that belongs_to user model, so I guess my mailer should contain something like @user.profile.first_name @user.profile.last_name.

1

1 Answers

1
votes

Just run

rails generate devise_invitable:views

And it'll generate local copies of the relevant views. Then you can edit that invite body in /app/views/devise/mailer/invitation_instructions.html.erb