Rails CDN Helper
Description
The gem is a CDN helper for Rails. The default CDN service is https://cdnjs.com/
.
Installation
- Put this into your Gemfile
gem 'rails-cdn-helper'
and run bundle install
.
- Start your rails application.
Usage
In the layout head add this code
<%= cdn_css 'font-awesome/4.7.0/css/font-awesome.min.css' %>
and output as below:
<link rel="stylesheet" media="screen" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
Overwrite CDN uri
-
Create
config/cdn.yml
-
Add content as below:
development:
uri: https://CDN_DOMAIN_NAME/
test:
uri: https://CDN_DOMAIN_NAME/
production:
uri: https://CDN_DOMAIN_NAME/
- Restart your rails application.