Skip to content

Instantly share code, notes, and snippets.

@maxivak
Last active May 24, 2017 11:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save maxivak/5239159 to your computer and use it in GitHub Desktop.
Save maxivak/5239159 to your computer and use it in GitHub Desktop.
Rails assets and CDN

Rails assets CDN

# serve all assets from CDN  server
config.action_controller.asset_host = 'http://cdn.mydomain.com'

#or if your files in a folder on CDN server
config.action_controller.asset_host = 'http://cdn.mydomain.com/myfolder'


# serve only images
config.action_controller.asset_host = Proc.new { |source|
    if source =~ /\b(.png|.jpg|.gif)\b/i
      "http://cdn.mydomain.com"
    end
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment