如何避免rails中“错误的参数数量”

时间:2010-08-04 04:11:08

标签: ruby-on-rails

我的控制器中有以下代码

  def create
    @employees = Group.find(params[:employee][:group_id]).employees
    puts "count!!!!" + @employees.count.to_s
    Communicate.deliver_message(params[:subject],@employees,params[:body].to_s)
    flash[:notice] = "your message has been sent"
    redirect_to root_url
  end

以下Communicate模型中的代码:

  def message(sub, people, msg)
    #puts "employee count!!!" + people.count
    subject    sub
    bcc        "my_email.s@gmail.com"
    from       'my_email.s@gmail.com'
    sent_on    Time.now

    body       :greeting => msg
  end

我得到的错误是create方法第3行的“错误的参数数量”。

1 个答案:

答案 0 :(得分:2)

如果它确实从ActionMailer :: Base继承,则问题是方法的名称:在ActionMailer中使用“message”。需要更改方法名称。