Usman Arshad Usman Arshad - 2 months ago 16
Ruby Question

Rails 4 & mail-2.5.4 - NoMethodError: undefined method `ascii_only?' for nil:NilClass

This error occurs on production server randomly not for every user. we are using sidekiq for delayed jobs and mandrill for emails. Please find the error backtrace form Airbrake.

My ActionMailer Method is:

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

Answer

Some of your three variables : email, subject, or message are nil.