I have a one codebase multiple apps setup on heroku. I am trying to display the host on the home page (stati_controller) which works on my main domain: www.domain.hu (env: production, production.rb) but doesn't on the other one: www.domain.co.uk (env: production-uk, production-uk.rb) Debug tells me: nil What am I missing?
Rails.application.default_url_options[:host] = 'www.domain.co.uk'
Rails.application.default_url_options[:host] = 'domain.co.uk'
config.asset_host = 'www.domain.co.uk' - this "kills" the CSS
config.default_url_options = { host: 'www.domain.co.uk' }
config.default_url_options[:host] = 'domain.co.uk'
config.action_controller.default_url_options = { host: 'www.domain.co.uk' }
config.action_controller.default_url_options = { host: 'domain.co.uk' }
Rails.application.default_url_options = { host: 'domain.co.uk' }
config.action_controller.default_url_options = { host: 'domain.co.uk' }
config.action_controller.default_url_options[:host] = 'domain.co.uk'
host = 'www.domain.co.uk'
config.action_controller.default_url_options = { host: host }
I also tried this in static_pages_controller.rb - no luck (with or without before-filter):
def default_url_options
if Rails.env == 'production'
{:host => "www.domain.hu"}
elsif Rails.env == 'production-uk'
{:host => "www.domain.co.uk"}
else
{}
end
end
And authenticate works based on request.host fine so I don't understand (static_pages_controller.rb):
before_filter :authenticate
...
def authenticate
domain = request.host
if domain == 'www.domain.hu'
authenticate_or_request_with_http_basic do |username, password| username == 'stuff' && password == 'boda'
end
elsif domain == 'www.domain.co.uk'
authenticate_or_request_with_http_basic do |username, password| username == 'stuff' && password == 'boda'
end
end
end
I have this in production-uk.rb too that works:
host = 'www.domain.co.uk'
config.action_mailer.default_url_options = { host: host }
UPDATE There is one more thing: When I am in the heroku console of the app and write app.host the reply is always "www.example.com"
Thanks for reading!
Aucun commentaire:
Enregistrer un commentaire