2

我正在尝试创建一个 foreach 循环,以便能够为添加到文本框中的每个电子邮件地址创建 invitaion_tokens 并发送所有电子邮件。

新的.html.erb

              <%= simple_form_for resource, :as => resource_name, :url => user_invitation_path(), :html => {:method => :post} do |f| %>
               <%= devise_error_messages! %>

              <div class="form-group">

              <% resource.class.invite_key_fields.each do |field| -%>
               <%= f.input :email, :class => "input-txt form-control" %><br />

              <% end -%>

               <%= f.submit t("devise.invitations.new.submit_button"), :id => "send-btn", :class => "btn btn-success" %>
              <% end %>

邀请控制器.rb

  def create
   self.resource = invite_resource

   if resource.errors.empty?
    yield resource if block_given?
    set_flash_message :notice, :send_instructions, :email => self.resource.email if self.resource.invitation_sent_at
    redirect_to root_path
   else
    respond_with_navigational(resource) { render :new }
   end
  end
4

0 回答 0