Skip to content

Instantly share code, notes, and snippets.

@pjhyett
Forked from dhh/gist:29752
Created November 28, 2008 07:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pjhyett/29940 to your computer and use it in GitHub Desktop.
Save pjhyett/29940 to your computer and use it in GitHub Desktop.
config.action_controller.asset_host = Proc.new do |source, request|
non_ssl_host = "http://asset#{source.hash % 4}.backpackit.com"
ssl_host = "https://asset1.backpackit.com"
if request.ssl?
case
when source =~ /\.js$/
ssl_host
when request.headers["USER_AGENT"] =~ /(Safari)/
non_ssl_host
when request.headers["USER_AGENT"] =~ /Firefox/ && source =~ /^\/images/
non_ssl_host
else
ssl_host
end
else
non_ssl_host
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment