ruby on rails - Is there a way to set set config.action_controller.asset_host in development -
in production.rb set asset_host cloudfront so:
config.action_controller.asset_host = 'http://xxxxxxxx.cloudfront.net'
now i'm finding in circumstances (specifically, outputting javascript embedded site) need set asset_host in development environment too, default null won't cut it. ideally want set:
config.action_controller.asset_host = 'http://localhost:3000'
but port can't guaranteed, , i'm reluctant hard-code it. there way set asset_host current domain , port?
thanks!
you can make use of environment variables or rails initializer parameters
config.action_controller.asset_host = env[asset_host].empty? ? 'http://' + rails::server.new.options[:host] + ':' + rails::server.new.options[:port] : env[asset_host]
this way if set environment variable use address otherwise use default.
Comments
Post a Comment