Note that there are some explanatory texts on larger screens.

plurals
  1. POArgumentError somewhere along the way from my ajax call to my ActionMailer
    primarykey
    data
    text
    <p>I'm making an ajax call. When I press send, I want to send an email, but I'm not even getting into anything in my controller action. It's as though the ajax call is messing up. I am sending three strings in the ajax call.</p> <p>I honestly don't know what is wrong and am completely baffled by it.</p> <p>Edit: After some testing, I am positive the error happens on the journey from my AJAX call to my server. I have no idea why.</p> <p>Ajax:</p> <pre><code>send: function() { var data = $('.sendEmail').serializeJSON(); $.ajax({ url: '/emails/send', type: 'POST', data: data, success: function(res) { console.log("oh yes!"); }, error: function(what) { console.log(what); } }); } </code></pre> <p>Route:</p> <pre><code>post 'emails/send', :to =&gt; "emails#send" </code></pre> <p>Controller Action:</p> <pre><code>def send email = params['email'] Mailer.email(email['recipients'], current_user.email, email['subject'], email['content']).deliver! render :json =&gt; email end </code></pre> <p>Mailer method:</p> <pre><code>def email(recipient, sender, subject, content) mail(:to =&gt; recipient, :from =&gt; sender, :body =&gt; content, :content_type =&gt; "text/html", :subject =&gt; subject) end </code></pre> <p>Error:</p> <pre><code>Started POST "/emails/send" for 127.0.0.1 at 2013-11-30 06:06:40 -0600 Processing by EmailsController#send as */* Parameters: {"email"=&gt;{"recipients"=&gt;"myemail@gmail.com", "subject"=&gt;"wowowowow", "content"=&gt;"omgomgomgomg"}} Completed 500 Internal Server Error in 1ms ArgumentError - wrong number of arguments (2 for 0): activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks' actionpack (3.2.13) lib/abstract_controller/callbacks.rb:17:in `process_action' actionpack (3.2.13) lib/action_controller/metal/rescue.rb:29:in `process_action' actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action' activesupport (3.2.13) lib/active_support/notifications.rb:123:in `block in instrument' activesupport (3.2.13) lib/active_support/notifications/instrumenter.rb:20:in `instrument' activesupport (3.2.13) lib/active_support/notifications.rb:123:in `instrument' actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:29:in `process_action' actionpack (3.2.13) lib/action_controller/metal/params_wrapper.rb:207:in `process_action' activerecord (3.2.13) lib/active_record/railties/controller_runtime.rb:18:in `process_action'....... </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload