Before you take any steps please back up your files and database.
This guide shows how to complete Ruby on Rails (RoR) CDN integration.
1. Create the desired CDN resource before starting integration with RoR.
2. To set your asset host in Rails, you need to change config.action_controller.asset_host inconfig/production.rb
config.action_controller.asset_host = 'cdn.example.com'
There’s no need to specify the protocol (http:// or https://) in the config file. Type in your CDN Domain ot the CNAME that you specified in the SkyparkCDN control panel. Ensure that your CNAME record has been configured in a proper way befor using it for integration.
3. You can also set this value through the environment variable in order to make integration easier.
config.action_controller.asset_host = ENV['CDN_HOST']
CDN_HOST needs to be set on your server (pointing to your CDN URL e.g. cdn.example.com).
4. Once you have configured your server, content can be delivered from CDN, for example:
<%= asset_path('file.png') %>
Instead of the path in the example /assets/file.png, the generated link should have the full path to your CDN resource as follows http://cdn.example.com/assets/smile.png
Integration has been completed! We highly recommend you to check the HTML code of your webpage to ensure that URLs have been rewritten properly from your original ones to CNAME from the control panel.
To do that press F12 or open Developers Tools in your browser, choose the Network tab and refresh the page. All static files should have your CNAME in URLs.