Missing host to link to! Please provide the :host parameter, for Rails 4
For Rails 5, use:
Rails.application.routes.default_url_options[:host] = "XXX"
You can put this in a config/environments/
file (or any other initializer), or e.g. at the beginning of config/routes.rb
.
Rails: Missing host to link to! Please provide :host parameter or set default_url_options[:host]
Your::Application.routes.draw do
default_url_options :host => "example.com"
# ... snip ...
end
Somewhere in routes.rb
:)
Missing host to link to! Please provide the :host parameter, set default_url_options[:host]
If you are using Rails 5, try this:
Rails.application.routes.default_url_options[:host] = "XXX"
Found this post about Rails 4 and there was a similar discussion in the Rails repository on Github
Heroku/devise - Missing host to link to! Please provide :host parameter or set default_url_options[:host]
You need to add this to your environment.rb
config.action_mailer.default_url_options = { :host => 'localhost' }
Make sure you change host
to your production url and keep it localhost for development. This is for the mailer, it needs a default email to send out notices such as confirmations etc...
You should check the logs on the heroku server heroku logs
run that from the console and it will tell you the exact error.
When you push to heroku you need to configure the environment.rb
file with the heroku subdomain:
config.action_mailer.default_url_options = { :host => 'yourapp.heroku.com' }
Depending upon version, this should go in production.rb
, not environment.rb
.
How do I resolve Missing host to link to! Please provide the :host parameter ? (RoR)
In the end I just used:
root_path
instead of:
root_url
ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
Spree::Auth::Config[:confirmable] = false
This line of code from prescription_photos_rest.rb
was overwritten buy a env value.
ActionView::Template::Error: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
In the end I added the following with the correct value to each environment file:
test.rb
/ development.rb
/ production.rb
Devise 3.2.x - 4.x.x
Rails 4.1.x && Rails 4.2.x && Rails 5.x.x
Thanks to maudulus
# Default Mailer Host
Rails.application.routes.default_url_options[:host] = 'domain.example'
Missing host to link to! Please provide :host parameter or set default_url_options[:host] (ActionView::Template::Error)
Cucumber runs your test environment so you need to add the very same line in test.rb
.
Related Topics
Array Include Any Value from Another Array
How to Round a Time Down to the Nearest 15 Minutes in Ruby
Determining If a Variable Is Within Range
Connect to a Locally Built Jekyll Server Using Mobile Devices in the Lan
Keep Getting Oauth::Unauthorized Error When Using Oauth and Twitter Ruby Gems
Ruby and Linux, Preferred Setup
How to Integrate Paypal with Ruby on Rails
Create Directory If It Doesn't Exist with Ruby
Complicated Graphviz Tree Structure
Check If a Constant Is Already Defined
Why Doesn't Ruby Have a Real Stringbuffer or Stringio
Difference Between Resource and Resources in Rails Routing
How to Check the Database Type in a Rails Migration
How to Convert a Ruby Object to JSON
What's the Difference Between These Ruby Namespace Conventions