1

下午好,

我有一个在 Heroku 上运行的应用程序,它具有相同的登台应用程序。两者之间的一切都应该完全相同,除了我已将 environment/production.rb 复制到 environment/staging.rb。

我也更改了环境变量:

RACK_ENV=staging
RAILS_ENV=staging

电子邮件将在我的生产应用程序上完全按预期发送,但是当我在我的暂存应用程序中发送一封时,它失败了:

!ruby/ActiveRecord:Delayed::Backend::ActiveRecord::Job 
  attributes: 
    id: 6
    priority: 0
    attempts: 2
    handler: |
      --- !ruby/object:Delayed::PerformableMailer 
      args: 
      - 3
      method_name: :admin_notification_signup
      object: !ruby/class UserMailer

    last_error: |-
      {undefined method `index' for :email:Symbol
      /app/vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/encodings.rb:117:in `value_decode'
      /app/vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/encodings.rb:101:in `decode_encode'
      /app/vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/fields/unstructured_field.rb:64:in `do_decode'
      /app/vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/fields/unstructured_field.rb:46:in `decoded'
      /app/vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/fields/unstructured_field.rb:115:in `fold'
      /app/vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/fields/unstructured_field.rb:96:in `wrapped_value'
      /app/vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/fields/unstructured_field.rb:60:in `do_encode'
      /app/vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/fields/unstructured_field.rb:42:in `encoded'
      /app/vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/field.rb:133:in `method_missing'
      /app/vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/header.rb:190:in `block in encoded'
      /app/vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/header.rb:189:in `each'
      /app/vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/header.rb:189:in `encoded'
      /app/vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/message.rb:1708:in `encoded'
      /app/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.3/lib/action_mailer/base.rb:433:in `set_payload_for_mail'
      /app/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.3/lib/action_mailer/base.rb:413:in `block in deliver_mail'
      /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/notifications.rb:123:in `block in instrument'
      /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
      /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/notifications.rb:123:in `instrument'
      /app/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.3/lib/action_mailer/base.rb:412:in `deliver_mail'
      /app/vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/message.rb:229:in `deliver'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/performable_mailer.rb:6:in `perform'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/backend/base.rb:94:in `block in invoke_job'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:60:in `call'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:60:in `block in initialize'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:65:in `call'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:65:in `execute'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:38:in `run_callbacks'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/backend/base.rb:91:in `invoke_job'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/worker.rb:178:in `block (2 levels) in run'
      /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/timeout.rb:68:in `timeout'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/worker.rb:178:in `block in run'
      /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/worker.rb:177:in `run'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/worker.rb:234:in `block in reserve_and_run_one_job'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:60:in `call'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:60:in `block in initialize'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:65:in `call'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:65:in `execute'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:38:in `run_callbacks'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/worker.rb:234:in `reserve_and_run_one_job'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/worker.rb:162:in `block in work_off'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/worker.rb:161:in `times'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/worker.rb:161:in `work_off'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/worker.rb:133:in `block (4 levels) in start'
      /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/worker.rb:132:in `block (3 levels) in start'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:60:in `call'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:60:in `block in initialize'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:65:in `call'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:65:in `execute'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:38:in `run_callbacks'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/worker.rb:129:in `block (2 levels) in start'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/worker.rb:128:in `loop'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/worker.rb:128:in `block in start'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/plugins/clear_locks.rb:7:in `call'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/plugins/clear_locks.rb:7:in `block (2 levels) in <class:ClearLocks>'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:78:in `call'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:78:in `block (2 levels) in add'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:60:in `call'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:60:in `block in initialize'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:78:in `call'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:78:in `block in add'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:65:in `call'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:65:in `execute'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:38:in `run_callbacks'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/worker.rb:127:in `start'
      /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.2/lib/delayed/tasks.rb:9:in `block (2 levels) in <top (required)>'
      /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
      /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
      /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
      /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
      /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
      /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
      /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
      /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
      /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
      /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
      /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
      /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
      /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
      /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
      /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
      /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
      /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
      /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
      /app/vendor/bundle/ruby/1.9.1/bin/rake:23:in `load'
      /app/vendor/bundle/ruby/1.9.1/bin/rake:23:in `<main>'
    run_at: 2012-06-02 20:49:55.976158 Z
    locked_at: 
    failed_at: 
    locked_by: 
    queue: 
    created_at: 2012-06-02 20:49:31.768212 Z
    updated_at: 2012-06-02 20:49:34.977784 Z    

有谁知道这可能是什么原因造成的?我正在使用 Roadie gem 来预先设置我的邮件样式。

user_mailer.rb:

class UserMailer < ActionMailer::Base

  default :css => :email, from: "Admin <admin@mysite.com>"

  host = ENV['HOST'].gsub(/http:\/\//, "")
  default_url_options[:host] = host

  ......

配置:

config.action_mailer.delivery_method = :smtp

config.action_mailer.default :charset => "utf-8"

config.action_mailer.smtp_settings = {
  :address              => "smtp.gmail.com",
  :port                 => "587",
  :domain               => "gmail.com",
  :user_name            => ENV['EMAIL_USER'],
  :password             => ENV['EMAIL_PASS'],
  :authentication       => "plain",
  :enable_starttls_auto => true
}
4

1 回答 1

1

作为数据点,当我遇到以下错误时,我遇到了同样的错误:

  default :css => :email

当我没有安装 roadie 时,在我的开发邮件中。因此,您可能会仔细检查您在两个环境中拥有的 gem 是否正确。

对于我们得到的错误,我认为基本上 Rails 的邮件部分会看到该:css => :email部分并说“我不知道这个符号是什么意思”。通常 roadie 会拦截它或以某种方式对其进行转换,但是当我没有安装它时,它并没有将它从参数中剥离出来,所以它一直到邮件程序。

于 2012-07-12T16:18:34.140 回答