生产服务器上随机发生此错误,而不是每个用户。我们使用sidekiq用于延迟作业和mandrill用于电子邮件。请找到Airbrake的错误回溯表。
我的ActionMailer方法是:
def auto_reply(email, subject, message)
mail(to: email, body: message, subject: subject)
end
/gems/mail-2.5.4/lib/mail/fields/common/parameter_hash.rb:44 in block in encoded
/gems/mail-2.5.4/lib/mail/fields/common/parameter_hash.rb:43 in map
/gems/mail-2.5.4/lib/mail/fields/common/parameter_hash.rb:43 in encoded
/gems/mail-2.5.4/lib/mail/fields/content_type_field.rb:113 in encoded
/gems/mail-2.5.4/lib/mail/field.rb:167 in method_missing
/gems/mail-2.5.4/lib/mail/header.rb:206 in block in encoded
/gems/mail-2.5.4/lib/mail/header.rb:205 in each
/gems/mail-2.5.4/lib/mail/header.rb:205 in encoded
/gems/mail-2.5.4/lib/mail/message.rb:1801 in encoded
/gems/mail-2.5.4/lib/mail/body.rb:153 in block in encoded
/gems/mail-2.5.4/lib/mail/parts_list.rb:11 in block in collect
/gems/mail-2.5.4/lib/mail/parts_list.rb:11 in each
/gems/mail-2.5.4/lib/mail/parts_list.rb:11 in collect
/gems/mail-2.5.4/lib/mail/body.rb:153 in encoded
/gems/mail-2.5.4/lib/mail/message.rb:1803 in encoded
/gems/actionmailer-4.0.8/lib/action_mailer/base.rb:475 in set_payload_for_mail
/gems/actionmailer-4.0.8/lib/action_mailer/base.rb:455 in block in deliver_mail
/gems/activesupport-4.0.8/lib/active_support/notifications.rb:159 in block in instrument
/gems/activesupport-4.0.8/lib/active_support/notifications/instrumenter.rb:20 in instrument
/gems/activesupport-4.0.8/lib/active_support/notifications.rb:159 in instrument
/gems/actionmailer-4.0.8/lib/action_mailer/base.rb:454 in deliver_mail
/gems/mail-2.5.4/lib/mail/message.rb:232 in deliver
/gems/sidekiq-3.2.4/lib/sidekiq/extensions/action_mailer.rb:20 in perform
/gems/sidekiq-3.2.4/lib/sidekiq/processor.rb:52 in block (2 levels) in process
/gems/sidekiq-3.2.4/lib/sidekiq/middleware/chain.rb:122 in call
/gems/sidekiq-3.2.4/lib/sidekiq/middleware/chain.rb:122 in block in invoke
/gems/sidekiq-3.2.4/lib/sidekiq/middleware/server/active_record.rb:6 in call
/gems/sidekiq-3.2.4/lib/sidekiq/middleware/chain.rb:124 in block in invoke
/gems/sidekiq-3.2.4/lib/sidekiq/middleware/server/retry_jobs.rb:74 in call
/gems/sidekiq-3.2.4/lib/sidekiq/middleware/chain.rb:124 in block in invoke
/gems/sidekiq-3.2.4/lib/sidekiq/middleware/server/logging.rb:11 in block in call
/gems/sidekiq-3.2.4/lib/sidekiq/logging.rb:22 in with_context
/gems/sidekiq-3.2.4/lib/sidekiq/middleware/server/logging.rb:7 in call
/gems/sidekiq-3.2.4/lib/sidekiq/middleware/chain.rb:124 in block in invoke
/gems/sidekiq-3.2.4/lib/sidekiq/middleware/chain.rb:127 in call
/gems/sidekiq-3.2.4/lib/sidekiq/middleware/chain.rb:127 in invoke
/gems/sidekiq-3.2.4/lib/sidekiq/processor.rb:51 in block in process
/gems/sidekiq-3.2.4/lib/sidekiq/processor.rb:94 in stats
/gems/sidekiq-3.2.4/lib/sidekiq/processor.rb:50 in process
/gems/celluloid-0.16.0/lib/celluloid/calls.rb:26 in public_send
/gems/celluloid-0.16.0/lib/celluloid/calls.rb:26 in dispatch
/gems/celluloid-0.16.0/lib/celluloid/calls.rb:122 in dispatch
/gems/celluloid-0.16.0/lib/celluloid/cell.rb:60 in block in invoke
/gems/celluloid-0.16.0/lib/celluloid/cell.rb:71 in block in task
/gems/celluloid-0.16.0/lib/celluloid/actor.rb:357 in block in task
/gems/celluloid-0.16.0/lib/celluloid/tasks.rb:57 in block in initialize
/gems/celluloid-0.16.0/lib/celluloid/tasks/task_fiber.rb:15 in block in create
答案 0 :(得分:2)
您的三个变量中的一些:email
,subject
或message
为nil
。
答案 1 :(得分:0)
我也有这个问题 - 使用Rails 4.1无论我在发送电子邮件时做了什么,我总是有可怕的
NoMethodError (undefined method `ascii_only?' for nil:NilClass):
对我来说,问题与我的邮件程序设置有关 - 其中一个组件,在这种情况下是SMTP服务器名称,未正确设置。
我使用本地文件进行半秘密设置,因此我的配置如下所示:
config.action_mailer.smtp_settings = {
:authentication => :plain,
:address => SECRET['SMTP_HOST'],
:port => SECRET['SMTP_PORT'],
:domain => SECRET['SMTP_DOMAIN'],
:user_name => SECRET['SMTP_USER'],
:password => SECRET['SMTP_PASS']
}
在application.rb中读取SECRET哈希,就像这样
secrets_file = "#{ENV['HOME']}/.secrets/myapp.yml"
SECRET = File.exists?(secrets_file) ? YAML.load_file(secrets_file) : {}
然后myapp.yml文件只包含YAML格式的键值对。
我得到ascii_only的原因?零错误是因为我只是遗漏了SMTP设置(在我的情况下是:地址) - 这导致了错误。