My ruby on rails action mailer runs all good in development environment, but in production environment, it keeps throw:
ActionView::Template::Error: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
My development config is
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:port => xxx,
:address => 'smtp.example.org',
:user_name => '[email protected]',
:password => 'xxxxxxxx',
:domain => 'xxxxxx.example',
:authentication => :plain,
}
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
My production config is
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:port => 587,
:address => 'smtp.example.org',
:user_name => '[email protected]',
:password => 'xxxxxx',
:domain => 'example.com',
:authentication => :plain,
}
config.action_mailer.default_url_options = { :host => 'example.com' }
My other environments are:
ruby 2.1.1
rails 4.0.3
sidekiq
devise
devise-async
I have tried:
Add the following in a initializer file
ActionMailer::Base.default_url_options[:host] = "example.com"
This answer here
Neither of them works.