![](/img/trans.png)
[英]URI::InvalidComponentError (bad component(expected scheme component): : https):
[英]URI::InvalidComponentError: bad component(expected host component): localhost:3000
我不確定出了什么問題,但是在控制台中運行NewsletterMailer.weekly("username-here@gmail.com").deliver
我收到錯誤URI::InvalidComponentError: bad component(expected host component): localhost:3000
我仔細檢查了我的設置,一切似乎都很好。 這是錯誤的完整 output:
from /Users/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/uri/generic.rb:605:in `check_host'
from /Users/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/uri/generic.rb:646:in `host='
from /Users/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/uri/generic.rb:195:in `initialize'
from /Users/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/uri/generic.rb:141:in `new'
from /Users/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/uri/generic.rb:141:in `build'
from /Users/.rvm/gems/ruby-2.0.0-p451/gems/roadie-2.4.3/lib/roadie/inliner.rb:206:in `absolute_url_base'
from /Users/.rvm/gems/ruby-2.0.0-p451/gems/roadie-2.4.3/lib/roadie/inliner.rb:192:in `ensure_absolute_url'
from /Users/.rvm/gems/ruby-2.0.0-p451/gems/roadie-2.4.3/lib/roadie/inliner.rb:180:in `block in make_image_urls_absolute'
from /Users/.rvm/gems/ruby-2.0.0-p451/gems/nokogiri-1.6.1/lib/nokogiri/xml/node_set.rb:237:in `block in each'
from /Users/.rvm/gems/ruby-2.0.0-p451/gems/nokogiri-1.6.1/lib/nokogiri/xml/node_set.rb:236:in `upto'
from /Users/.rvm/gems/ruby-2.0.0-p451/gems/nokogiri-1.6.1/lib/nokogiri/xml/node_set.rb:236:in `each'
from /Users/.rvm/gems/ruby-2.0.0-p451/gems/roadie-2.4.3/lib/roadie/inliner.rb:179:in `make_image_urls_absolute'
from /Users/.rvm/gems/ruby-2.0.0-p451/gems/roadie-2.4.3/lib/roadie/inliner.rb:57:in `block in execute'
from /Users/.rvm/gems/ruby-2.0.0-p451/gems/roadie-2.4.3/lib/roadie/inliner.rb:80:in `block in adjust_html'
from /Users/.rvm/gems/ruby-2.0.0-p451/gems/roadie-2.4.3/lib/roadie/inliner.rb:79:in `tap'
from /Users/.rvm/gems/ruby-2.0.0-p451/gems/roadie-2.4.3/lib/roadie/inliner.rb:79:in `adjust_html'
... 10 levels...
from /Users/.rvm/gems/ruby-2.0.0-p451/gems/actionpack-4.0.0.rc1/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
from /Users/.rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.0.rc1/lib/active_support/callbacks.rb:392:in `_run__4195001508967449441__process_action__callbacks'
from /Users/.rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.0.rc1/lib/active_support/callbacks.rb:80:in `run_callbacks'
from /Users/.rvm/gems/ruby-2.0.0-p451/gems/actionpack-4.0.0.rc1/lib/abstract_controller/callbacks.rb:17:in `process_action'
from /Users/.rvm/gems/ruby-2.0.0-p451/gems/actionpack-4.0.0.rc1/lib/abstract_controller/base.rb:136:in `process'
from /Users/.rvm/gems/ruby-2.0.0-p451/gems/actionpack-4.0.0.rc1/lib/abstract_controller/rendering.rb:44:in `process'
from /Users/.rvm/gems/ruby-2.0.0-p451/gems/actionmailer-4.0.0.rc1/lib/action_mailer/base.rb:503:in `process'
from /Users/.rvm/gems/ruby-2.0.0-p451/gems/actionmailer-4.0.0.rc1/lib/action_mailer/base.rb:497:in `initialize'
from /Users/.rvm/gems/ruby-2.0.0-p451/gems/actionmailer-4.0.0.rc1/lib/action_mailer/base.rb:480:in `new'
from /Users/.rvm/gems/ruby-2.0.0-p451/gems/actionmailer-4.0.0.rc1/lib/action_mailer/base.rb:480:in `method_missing'
from (irb):1
from /Users/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.0.rc1/lib/rails/commands/console.rb:90:in `start'
from /Users/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.0.rc1/lib/rails/commands/console.rb:9:in `start'
from /Users/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.0.rc1/lib/rails/commands.rb:66:in `<top (required)>'
開發.rb:
config.cache_classes = false
config.eager_load = false
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_mailer.raise_delivery_errors = false
config.active_support.deprecation = :log
config.assets.debug = true
config.eager_load = false
# Change mail delvery to either :smtp, :sendmail, :file, :test
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'gmail.com',
user_name: 'username-here@gmail.com',
password: 'password-here',
authentication: 'plain',
enable_starttls_auto: false }
config.action_mailer.default_url_options = { :host => "localhost:3000" }
end
從您指定為默認主機的URL中刪除端口號。 :host
密鑰的值應該只是主機,而不是主機和端口號。
如果Zajn的答案不起作用,那么搜索localhost:3000
。 你可能把它放在其他地方。 當你發現它刪除該行,它應該工作。
您可能在配置中的某處有一行config.roadie.url_options = { host: "localhost:3000" }
,也許是development.rb。 road.url_options要求將端口指定為單獨的密鑰。
請嘗試使用config.roadie.url_options = { host: "localhost", port: 3000 }
。
我遇到了同樣的問題,嘗試用這個命令啟動服務器
bundle exec rails server -b 127.0.0.1
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.