6

I want to be able to show the user that sent out the invitation rather than just my domain when sending out a devise invitation but haven't been able to find any documentation on this.

The two places where I need to show this name are in the invitation email-

(in place of 'Someone')

<p>Hello <%= @resource.email %>!</p>

<p>Someone has invited you to <%= root_url %>, you can accept it through the link below.</p>

<p><%= link_to 'Accept invitation', accept_invitation_url(@resource, :invitation_token => @resource.invitation_token) %></p>

<p>If you don't want to accept the invitation, please ignore this email.<br />
Your account won't be created until you access the link above and set your password.</p>

and the set password page.

<h4>You're seeing this page because someone has invited you to the site</h4>
<%= simple_form_for resource, :as => resource_name, :url => invitation_path(resource_name), :html => { :method => :put } do |f| %>
  <%= devise_error_messages! %>
  <%= f.hidden_field :invitation_token %>
<div class="row">  
  <div class="signup_well span3 offset1">
    <legend><%= t 'devise.invitations.edit.header' %></legend>
    <%= f.input :password %>
    <%= f.input :password_confirmation %>
    <%= hidden_field_tag :token_key, resource.invitation_token %>
    <%= f.submit t("devise.invitations.edit.submit_button") %>
  <% end %>
</div>

I may over looking any documentation on the best approach to do this. Your help saves a lot of frustration. Thank you.

computer_smile
  • 2,117
  • 2
  • 24
  • 42
  • Why wouldn't I have access to <%= @resource.first_name %> if the inviter enters in the first and last name when filling out the invitation form (along with the email). – computer_smile Jan 27 '13 at 22:31

1 Answers1

5

This should works: <%= @resource.invited_by.first_name %>.

Eric Wong
  • 524
  • 9
  • 21
  • Still getting an undefined method `invited_by' for nil:NilClass error. – computer_smile Feb 02 '13 at 21:24
  • 3
    This will work, but you need to pass the inviter when you call `invite!` method. Like `User.invite!({email:email}, current_user)` – n_i_c_k Mar 25 '13 at 21:33
  • Do you know how I can put the inviter's name in the email's subject line? Is there a way to access the inviter name from the `devise_invitable.en.yml` file? – RocketGuy3 Sep 28 '16 at 06:57