坏组件(预期的主机组件):在运行rake任务时收到,以便在heroku上发送带有roadie的电子邮件

时间:2014-02-25 05:24:06

标签: ruby-on-rails heroku actionmailer rake-task

我正在使用roadie gem来帮助处理电子邮件的内联css,并在运行rake任务发送电子邮件时收到以下错误。我的应用程序托管在heroku上。它在开发模式下工作正常,但在生产中出现此错误。我不太明白这个问题。其他邮件在生产中发送正常。我几乎是初学者。在此先感谢您的帮助!

rake aborted!
bad component(expected host component): http://nameless-taiga-7547.herokuapp.com/
/app/vendor/ruby-1.9.2/lib/ruby/1.9.1/uri/generic.rb:395:in `check_host'
/app/vendor/ruby-1.9.2/lib/ruby/1.9.1/uri/generic.rb:409:in `host='
/app/vendor/ruby-1.9.2/lib/ruby/1.9.1/uri/generic.rb:180:in `initialize'
/app/vendor/ruby-1.9.2/lib/ruby/1.9.1/uri/generic.rb:126:in `new'
/app/vendor/ruby-1.9.2/lib/ruby/1.9.1/uri/generic.rb:126:in `build'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie/inliner.rb:206:in `absolute_url_base'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie/inliner.rb:192:in      `ensure_absolute_url'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie/inliner.rb:180:in `block in make_image_urls_absolute'
/app/vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.6/lib/nokogiri/xml/node_set.rb:239:in `block in each'
/app/vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.6/lib/nokogiri/xml/node_set.rb:238:in `upto'
/app/vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.6/lib/nokogiri/xml/node_set.rb:238:in `each'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie/inliner.rb:179:in `make_image_urls_absolute'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie/inliner.rb:57:in `block in execute'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie/inliner.rb:80:in `block in adjust_html'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie/inliner.rb:79:in `tap'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie/inliner.rb:79:in `adjust_html'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie/inliner.rb:51:in `execute'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie.rb:6:in `inline_css'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie/action_mailer_extensions.rb:75:in `inline_style_response'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie/action_mailer_extensions.rb:54:in `block in collect_responses_and_parts_order_with_inline_styles'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie/action_mailer_extensions.rb:54:in `map'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie/action_mailer_extensions.rb:54:in `collect_responses_and_parts_order_with_inline_styles'
/app/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.11/lib/action_mailer/base.rb:648:in `mail'
/app/vendor/bundle/ruby/1.9.1/gems/roadie-2.4.3/lib/roadie/action_mailer_extensions.rb:35:in `mail_with_inline_styles'
/app/app/mailers/match_mailer.rb:13:in `deal_match'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.11/lib/abstract_controller/base.rb:167:in `process_action'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.11/lib/abstract_controller/base.rb:121:in `process'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.11/lib/abstract_controller/rendering.rb:45:in `process'
/app/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.11/lib/action_mailer/base.rb:458:in `process'
/app/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.11/lib/action_mailer/base.rb:452:in `initialize'
/app/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.11/lib/action_mailer/base.rb:439:in `new'
/app/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.11/lib/action_mailer/base.rb:439:in `method_missing'
/app/lib/tasks/match.rake:24:in `block (3 levels) in <top (required)>'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/relation/delegation.rb:6:in `each'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/relation/delegation.rb:6:in `each'
/app/lib/tasks/match.rake:20:in `block (2 levels) in <top (required)>'
/app/lib/tasks/match.rake:9:in `each'
/app/lib/tasks/match.rake:9:in `block in <top (required)>'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/app/vendor/ruby-1.9.2/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/app/vendor/bundle/ruby/1.9.1/bin/rake:19:in `load'
/app/vendor/bundle/ruby/1.9.1/bin/rake:19:in `<main>'

在我的佣金任务中

task :match => :environment do
...
end

以下是我的production.rb

中的内容
config.cache_classes = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.serve_static_assets = false
config.assets.compress = true
config.assets.compile = true
config.assets.digest = true
config.action_mailer.asset_host = { :host => 'http://nameless-taiga-7547.herokuapp.com/' }

ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => 'example',
:password => 'password',
:domain => 'heroku.com'
}

ActionMailer::Base.delivery_method = :smtp
config.action_mailer.default_url_options = { :host => 'http://nameless-taiga-7547.herokuapp.com/' }

1 个答案:

答案 0 :(得分:2)

要求您提供主机名,但您提供了完整的URI。你应该只提供主持人:

config.action_mailer.asset_host = { :host => 'nameless-taiga-7547.herokuapp.com' }
config.action_mailer.default_url_options = { :host => 'nameless-taiga-7547.herokuapp.com' }