views:

373

answers:

1

I read that by setting ActionController::Base.asset_host, you can control where rails looks for assets. However, by default Rails should look in '/public/...'

Somehow my Rails app knows to look at my production address when in development mode and I have not set ActionController::Base.asset_host anywhere. I am not sure where it is finding this information. Is there anywhere else this can be set? I don't think my deploy recipes should have anything to do with it...

<%= image_tag 'my_logo.png' %>

causes Rails to check my production server for the file. Same with stylesheets.

A: 

I am not quite sure how Rails knew to look for my production domain. I removed it almost everywhere in my code. According to the docs, "By default, Rails links to these assets on the current host in the public folder" but I am not quite sure what that means. To prevent this from ever being an issue again and to allow some flexible configuration, I added asset host domains to my environment configuration. I now have something like:

EnvironmentConfig = YAML.load(File.read(Rails.root + "config/#{rails_env}" + 'environment.yml'))[rails_env]

ActionController::Base.asset_host = EnvironmentConfig['asset_host']

Everything works great now. Still don't know how Rails knew to look at my production domain.

Tony