我不确定有什么问题,但在运行NewsletterMailer.weekly("username-here@gmail.com").deliver
时在控制台中我收到错误URI::InvalidComponentError: bad component(expected host component): localhost:3000
我仔细检查我的设置,一切似乎都很好。这是错误的完整输出:
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)>'
Development.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
答案 0 :(得分:5)
从您指定为默认主机的网址中删除端口号。 :host
密钥的值应该只是主机,而不是主机和端口号。
答案 1 :(得分:2)
如果Zajn的回答不起作用,请搜索localhost:3000
。你可能把它放在其他地方。当你发现它删除了它,它应该工作。
答案 2 :(得分:2)
您的配置中某处可能有config.roadie.url_options = { host: "localhost:3000" }
行,也许是development.rb。
road.url_options要求将端口指定为单独的密钥。
尝试
而是config.roadie.url_options = { host: "localhost", port: 3000 }
。