Patrick
Patrick

Reputation: 475

how to avoid "wrong number of arguments" in rails

I have following code in my controller

  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

following code in Communicate model:

  def message(sub, people, msg)
    #puts "employee count!!!" + people.count
    subject    sub
    bcc        "[email protected]"
    from       '[email protected]'
    sent_on    Time.now

    body       :greeting => msg
  end

Error I am getting is "wrong number of arguments" on 3rd line of the create method.

Upvotes: 0

Views: 644

Answers (1)

Maximiliano Guzman
Maximiliano Guzman

Reputation: 2035

if it did inherit from ActionMailer::Base, then the problem is the name of the method: "message" is used inside ActionMailer. Need to change the method name.

Upvotes: 2

Related Questions