我遇到以下問題。嘗試爲ActionMailer呈現模板時,我的Resque後臺作業失敗。但是這隻有在我處於生產環境時纔會發生。爲什麼Rails ActionMailer會在生產環境中引發路由錯誤?
錯誤與路由錯誤有關。這裏是堆棧跟蹤:
/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無關。禁用重新發送郵件後,我可以複製該問題。因此,生產中的ActionMailer會導致此問題。
UPDATE 2問題似乎出現在Rails 3.0.11和3.0.12上。 3.0.10工作正常。
這是堆棧跟蹤,但它的實際錯誤信息是什麼? – 2012-03-12 16:02:53
@AndrewMarshall'ActionView :: Template :: Error' – 2012-03-12 20:55:19