Javascript 从ajax调用到ActionMailer的过程中的某个地方出现了ArgumentError
我在打ajax电话。当我按send时,我想发送一封电子邮件,但我的控制器操作中甚至没有涉及任何内容。似乎ajax调用正在出错。我在ajax调用中发送了三个字符串 老实说,我不知道是什么错了,我完全被它弄糊涂了 编辑:经过一些测试,我确信错误发生在从AJAX调用到服务器的过程中。我不知道为什么 阿贾克斯: 路线:Javascript 从ajax调用到ActionMailer的过程中的某个地方出现了ArgumentError,javascript,ajax,ruby-on-rails-3,Javascript,Ajax,Ruby On Rails 3,我在打ajax电话。当我按send时,我想发送一封电子邮件,但我的控制器操作中甚至没有涉及任何内容。似乎ajax调用正在出错。我在ajax调用中发送了三个字符串 老实说,我不知道是什么错了,我完全被它弄糊涂了 编辑:经过一些测试,我确信错误发生在从AJAX调用到服务器的过程中。我不知道为什么 阿贾克斯: 路线: post 'emails/send', :to => "emails#send" 控制器操作: def send email = params['email']
post 'emails/send', :to => "emails#send"
控制器操作:
def send
email = params['email']
Mailer.email(email['recipients'], current_user.email, email['subject'], email['content']).deliver!
render :json => email
end
梅勒方法:
def email(recipient, sender, subject, content)
mail(:to => recipient, :from => sender, :body => content, :content_type => "text/html", :subject => subject)
end
错误:
Started POST "/emails/send" for 127.0.0.1 at 2013-11-30 06:06:40 -0600
Processing by EmailsController#send as */*
Parameters: {"email"=>{"recipients"=>"myemail@gmail.com", "subject"=>"wowowowow", "content"=>"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'.......
好的,我刚刚在我的Rails控制台上对Heroku进行了测试,我知道邮件程序是有效的。如果我叫它,它就行了。错误发生在AJAX调用和访问我的服务器之间。在该操作中是否有任何之前或周围的过滤器?
Started POST "/emails/send" for 127.0.0.1 at 2013-11-30 06:06:40 -0600
Processing by EmailsController#send as */*
Parameters: {"email"=>{"recipients"=>"myemail@gmail.com", "subject"=>"wowowowow", "content"=>"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'.......