17 SEPTEMBER 2009
Sometimes you reach a point with a Website where it gets difficult to properly style the site if you don’t have the right assets on your local machine. The database and the assets are always changing and growing due to user input.
You could alway download the latest assets, but sometimes there are to big to download or you just don’t want to keep the assets on your local machine.
One solution to this problem is to set up an Asset Host. You can easily add an Asset Host in the environments/development.rb
ActionController::Base.asset_host = "assets.example.com"
Every single asset comes from the assets.example.com host. Thats fine, until you realize that the javascript and css files comes from the host too (Yes, it took me about 15 min to realize why my changes in the css didnt’t work ;).
So here is the solution for the problem:
ActionController::Base.asset_host = Proc.new { |source|
if source.starts_with?('/assets')
"gameone.de"
else
"http://localhost:3000"
end
}
I put the code in an initializers and ignored it from git.
initializers/config_local_asset_host.rb
if Rails.env == "development"
ActionController::Base.asset_host = Proc.new { |source|
if source.starts_with?('/assets')
"gameone.de"
else
"http://localhost:3000"
end
}
end
Thx to @Soph to point me in the right direction !
Magento powered fabric store for organic cotton
Mass Customization Fashion Label from Germany
Blog- and Community site for the first Game-TV-Show on MTV Germany.
MTV Home is one of MTV Microsite's wich runs on the new developed Rails-Microsite-Engine at MTV Germany.
Game-Based Learning Platform for kids.
Modéliste . Creative Pattern Cutter
Rails Programmer
Rails Programmer