Rails devise_invitable立即向多个电子邮件发送邀请

时间:2014-03-28 17:01:27

标签: ruby-on-rails ruby foreach devise devise-invitable

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

new.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 %>

invitations_controller.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

0 个答案:

没有答案