views:

17

answers:

2

I want Rails 3 to dynamically grab assets depending on current domain:

mysite.com - assets.mysite.com mysite.ru - assets.mysite.ru

Is it possible out of the box? Or I should implement it manually?

A: 

Are you meaning subdomains?

subdomains(tld_length = 1)

Returns all the subdomains as an array, so ["dev", "www"] would be returned for “dev.www.rubyonrails.org“. You can specify a different tld_length, such as 2 to catch ["www"] instead of ["www", "rubyonrails"] in “www.rubyonrails.co.uk“.
Yannis
A: 

In config/environments/production.rb etc.

config.action_controller.asset_host = "http://assets." << request.host
ghoppe
We tried this, but rails fails to find request object. It seems that it is not exist during initialization
Oksana