设计可邀的节目邀请者姓名或电子邮件

com*_*ile 6 email invitation devise ruby-on-rails-3

我希望能够在发送设计邀请时显示发出邀请的用户而不仅仅是我的域名,但无法找到任何相关文档.

我需要显示此名称的两个地方在邀请电子邮件中 ​​-

(代替'某人')

<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>
Run Code Online (Sandbox Code Playgroud)

和设置密码页面.

<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>
Run Code Online (Sandbox Code Playgroud)

我可能会过度查找有关执行此操作的最佳方法的任何文档.你的帮助可以节省很多挫折感.谢谢.

Eri*_*ong 5

这应该有效:<%= @ resource.invited_by.first_name%>.

  • 这样可以工作,但是当你调用`invite!`方法时需要传递inviter.就像`User.invite!({email:email},current_user)` (3认同)