gpt4 book ai didi

actionmailer - Rails 3.1RC4 Mailer 邮件方法返回错误数量的参数(0 代表 1)

转载 作者:行者123 更新时间:2023-12-04 06:17:58 26 4
gpt4 key购买 nike

我有一个非常标准的邮件程序类,使用以下方法:

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)

我的第一个想法是传入的参数,但一些调试/规范确认错误发生在 mail(: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
分配 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
新的'
来自/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
使成为'
来自/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
要求'
来自/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
过程'
来自/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
过程'
来自/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
初始化'
来自/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
要求'

最佳答案

我遇到过同样的问题。好像ActionMailer::Base不喜欢你使用 request发送电子邮件的方法。更改方法的名称,它将起作用。

关于actionmailer - Rails 3.1RC4 Mailer 邮件方法返回错误数量的参数(0 代表 1),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6992910/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com