为什么Rails ActionMailer会在生产环境中引发路由错误?

时间:2012-03-12 14:08:50

标签: ruby-on-rails-3 actionmailer

我遇到以下问题。尝试为ActionMailer呈现模板时,My Resque后台作业失败。但这只有在我处于生产环境时才会发生。

错误与路由错误有关。这是堆栈跟踪:

/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionpack-3.0.11/lib/action_dispatch/routing/route_set.rb:425:in `raise_routing_error'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionpack-3.0.11/lib/action_dispatch/routing/route_set.rb:407:in `rescue in generate'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionpack-3.0.11/lib/action_dispatch/routing/route_set.rb:396:in `generate'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionpack-3.0.11/lib/action_dispatch/routing/route_set.rb:454:in `generate'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionpack-3.0.11/lib/action_dispatch/routing/route_set.rb:482:in `url_for'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionpack-3.0.11/lib/action_dispatch/routing/url_for.rb:131:in `url_for'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionpack-3.0.11/lib/action_view/helpers/url_helper.rb:99:in `url_for'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionpack-3.0.11/lib/action_dispatch/routing/route_set.rb:195:in `account_case_url'
/home/foo/production/source/app/views/case_mailer/case_creation.html.erb:3:in `_app_views_case_mailer_case_creation_html_erb__56964564007999368_36702160_384137435874551441'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionpack-3.0.11/lib/action_view/template.rb:162:in `block in render'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/activesupport-3.0.11/lib/active_support/notifications.rb:54:in `instrument'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionpack-3.0.11/lib/action_view/template.rb:154:in `render'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionpack-3.0.11/lib/action_view/render/rendering.rb:59:in `block in _render_template'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/activesupport-3.0.11/lib/active_support/notifications.rb:52:in `block in instrument'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/activesupport-3.0.11/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/activesupport-3.0.11/lib/active_support/notifications.rb:52:in `instrument'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionpack-3.0.11/lib/action_view/render/rendering.rb:56:in `_render_template'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionpack-3.0.11/lib/action_view/render/rendering.rb:26:in `render'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionpack-3.0.11/lib/abstract_controller/rendering.rb:115:in `_render_template'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionpack-3.0.11/lib/abstract_controller/rendering.rb:109:in `render_to_body'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionpack-3.0.11/lib/abstract_controller/rendering.rb:102:in `render_to_string'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionpack-3.0.11/lib/abstract_controller/rendering.rb:93:in `render'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.0.11/lib/action_mailer/deprecated_api.rb:111:in `render'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.0.11/lib/action_mailer/base.rb:735:in `block in collect_responses_and_parts_order'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.0.11/lib/action_mailer/base.rb:750:in `each'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.0.11/lib/action_mailer/base.rb:750:in `block in each_template'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.0.11/lib/action_mailer/base.rb:745:in `each'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.0.11/lib/action_mailer/base.rb:745:in `each_template'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.0.11/lib/action_mailer/base.rb:731:in `collect_responses_and_parts_order'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.0.11/lib/action_mailer/base.rb:673:in `mail'
/home/foo/production/source/app/mailers/case_mailer.rb:13:in `case_creation'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionpack-3.0.11/lib/abstract_controller/base.rb:150:in `process_action'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionpack-3.0.11/lib/abstract_controller/base.rb:119:in `process'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionpack-3.0.11/lib/abstract_controller/rendering.rb:41:in `process'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.0.11/lib/action_mailer/old_api.rb:75:in `process'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.0.11/lib/action_mailer/base.rb:471:in `process'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.0.11/lib/action_mailer/base.rb:466:in `initialize'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/resque_mailer-1.0.1/lib/resque_mailer/rails3.rb:16:in `new'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/resque_mailer-1.0.1/lib/resque_mailer/rails3.rb:16:in `deliver!'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/resque_mailer-1.0.1/lib/resque_mailer/rails3.rb:37:in `perform'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/resque-1.17.1/lib/resque/job.rb:127:in `perform'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/resque-1.17.1/lib/resque/worker.rb:163:in `perform'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/resque-1.17.1/lib/resque/worker.rb:130:in `block in work'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/resque-1.17.1/lib/resque/worker.rb:116:in `loop'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/resque-1.17.1/lib/resque/worker.rb:116:in `work'
script/resque_worker:13:in `start'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/daemon-spawn-0.4.2/lib/daemon_spawn.rb:51:in `block in start'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/daemon-spawn-0.4.2/lib/daemon_spawn.rb:38:in `fork'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/daemon-spawn-0.4.2/lib/daemon_spawn.rb:38:in `start'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/daemon-spawn-0.4.2/lib/daemon_spawn.rb:181:in `block in start'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/daemon-spawn-0.4.2/lib/daemon_spawn.rb:181:in `map'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/daemon-spawn-0.4.2/lib/daemon_spawn.rb:181:in `start'
/home/foo/production/source/vendor/bundle/ruby/1.9.1/gems/daemon-spawn-0.4.2/lib/daemon_spawn.rb:165:in `spawn!'
script/resque_worker:22:in `<main>'

我的视图模板中的代码如下:

link_to _("Click here to see the case"), 
        account_case_url(:only_path => false, 
                         :host => "production.foo.com",
                         :controller => "cases",
                         :action => "show",
                         :id => @case.id, :account_id => @case.account.id)

我知道有similar post on SO但是,答案没有给出。此外,我不得不再次说,我的问题只出现在生产环境中。

更新我必须再说一遍,这与resque无关。我可以在禁用resque邮件程序后复制该问题。因此,生产中的ActionMailer导致了这个问题。

更新2 Rails 3.0.11和3.0.12上似乎存在问题。 3.0.10工作正常。

1 个答案:

答案 0 :(得分:0)

回滚到Rails 3.0.10。 Bug存在于3.0.11和3.0.12。