Rails 3.1+ I want my url helpers to use the https protocol without having to specify it in every helper I call. After searching around I've found various ways but none work, for example:
ROUTES_PROTOCOL = (ENV["RAILS_ENV"] =~ /development/ ? 'http://' : 'https://')
scope :protocol => ROUTES_PROTOCOL, :path => "/app" do
How can this be done?
So you want it mainly for links in emails?
I think this will work in your production.rb, development.rb or any other environment.
config.action_mailer.default_url_options = {
:host => 'yourwebsite.com',
:protocol => 'https'
}
# Makes it possible to use image_tag in mails
config.action_mailer.asset_host = "https://yourwebsite.com"