我有一个非常标准的邮件程序类,使用以下方法:
def request(contact_us)
@contact = contact_us
mail(:to => "customercare@our_co.com", :subject => @contact.subject, :from => @contact.email)
end
我得到的错误是:
wrong number of arguments (0 for 1)
我的第一个想法是传入的参数,但是一些调试/规范确认错误发生在邮件的行上(:to。整个跟踪在下面,第9行是定义方法的地方,第11行是邮件方法。我查看了rails代码,这是实际上在ActionView :: Base中躲避的方法
assign_controller(controller)
有什么想法或建议吗?我也尝试过RC5,结果相同。
谢谢!
ArgumentError:参数数量错误(0表示1)
来自/Users/user/Git/projects/app/mailers/notifier.rb:9:in request'
from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionpack-3.1.0.rc4/lib/action_view/helpers/controller_helper.rb:15:in
assign_controller'
来自/Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionpack-3.1.0.rc4/lib/action_view/base.rb:212:in initialize'
from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionpack-3.1.0.rc4/lib/abstract_controller/rendering.rb:87:in
new'
来自/Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionpack-3.1.0.rc4/lib/abstract_controller/rendering.rb:87:in view_context'
from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionpack-3.1.0.rc4/lib/abstract_controller/rendering.rb:120:in
_ render_template'
来自/Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionpack-3.1.0.rc4/lib/abstract_controller/rendering.rb:114:in render_to_body'
from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionpack-3.1.0.rc4/lib/abstract_controller/rendering.rb:99:in
render'
来自/Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionmailer-3.1.0.rc4/lib/action_mailer/base.rb:717:in block in collect_responses_and_parts_order'
from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionmailer-3.1.0.rc4/lib/action_mailer/base.rb:728:in
每个'
来自/Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionmailer-3.1.0.rc4/lib/action_mailer/base.rb:728:in each_template'
from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionmailer-3.1.0.rc4/lib/action_mailer/base.rb:713:in
collect_responses_and_parts_order'
来自/Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionmailer-3.1.0.rc4/lib/action_mailer/base.rb:652:in mail'
from /Users/user/Git/projects/app/mailers/notifier.rb:11:in
request'
来自/Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionpack-3.1.0.rc4/lib/abstract_controller/base.rb:167:in process_action'
from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionpack-3.1.0.rc4/lib/abstract_controller/base.rb:121:in
process'
来自/Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionpack-3.1.0.rc4/lib/abstract_controller/rendering.rb:45:in process'
from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionmailer-3.1.0.rc4/lib/action_mailer/old_api.rb:65:in
process'
来自/Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionmailer-3.1.0.rc4/lib/action_mailer/base.rb:473:in process'
from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionmailer-3.1.0.rc4/lib/action_mailer/base.rb:468:in
initialize'
来自/Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionmailer-3.1.0.rc4/lib/action_mailer/base.rb:455:in new'
from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionmailer-3.1.0.rc4/lib/action_mailer/base.rb:455:in
method_missing'
来自(irb):13
来自/Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/railties-3.1.0.rc4/lib/rails/commands/console.rb:45:in start'
from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/railties-3.1.0.rc4/lib/rails/commands/console.rb:8:in
开始“
来自/Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/railties-3.1.0.rc4/lib/rails/commands.rb:40:in <top (required)>'
from script/rails:6:in
要求'< / p>
答案 0 :(得分:3)
我有同样的问题。似乎ActionMailer::Base
不喜欢您使用request
方法发送电子邮件。更改方法的名称,它将起作用。