Rails 4语法错误与动作邮件

时间:2014-07-01 14:17:42

标签: ruby-on-rails-4 actionmailer

突然间,我的邮件发生了故障。这是一个向管理员发送请求电子邮件的简单表单。我不断收到奇怪的语法错误。也许有人可以帮助我!

RequestMailer.rb

  class RequestMailer < ActionMailer::Base
    default from: "no-reply@bethelmusic.org"

     def request_submit(request_form)
     @request_form = request_form
     mail :to => (AdminUser.select(:email).map(&:email), :subject => "New design request")
   end
 end

Request_submit.html.erb

 <h3>
  Name: <%= @request_form[:Name] %></br>

  Email: <%= @request_form[:Email] %></br>

  Project: <%= @request_form[:Project] %></br>

  Description: <%= @request_form[:Description] %></br>

  Dimensions: <%= @request_form[:Dimensions] %></br>

  References: <%= @request_form[:design_file] %></br>

  Due Date: <%= @request_form[:Due_Date] %></br>

  Dropbox Link: <%= @request_form[:Link] %></br>

  Comments: <%= @request_form[:Comments] %></br>
</h3>

请求表单控制器

def create
 @request_form = RequestForm.new(request_form_params)

 respond_to do |format|
  if @request_form.save
    RequestMailer.request_submit(@request_form).deliver  <-- #HERE IS WHERE THE "ERROR" IS
    format.html { render partial: "success" }
    format.json { render action: 'show', status: :created, location: @request_form }
  else
    format.html { render action: 'new' }
    format.json { render json: @request_form.errors, status: :unprocessable_entity }
   end
 end
end

所以我得到的错误是&#34;语法错误,意外&#39;,&#39;,期待&#39;)&#39; &#34; 我没有&#39;,&#39;在那里,没有必要为什么要求一个亲密的人。

请思考和帮助!谢谢!

1 个答案:

答案 0 :(得分:1)

:to => (AdminUser.select(:email).map(&:email), :subject => "New design request")

options[:to]的值根本不像哈希。它不是有效的语法,除非前面加上方法名称,否则不是这样。应该是这样的:

:to => AdminUser.select(:email).map(&:email), :subject => "New design request"

但如果你坚持用大括号围住它,那就这样做:

{:to => AdminUser.select(:email).map(&:email), :subject => "New design request"}