Skip to content

Instantly share code, notes, and snippets.

@alameenkhader
Last active August 29, 2015 14:06
Show Gist options
  • Save alameenkhader/d3fc6b2c1bbb8b698e4f to your computer and use it in GitHub Desktop.
Save alameenkhader/d3fc6b2c1bbb8b698e4f to your computer and use it in GitHub Desktop.
Rails with bootstrap
  • Download bootstrap
  • Add bootstrap.js to vendor/assets/javascripts
  1. Add the following to app/assets/application.js
    //= require bootstrap
  2. Add bootstrap.css to vendor/assets/stylesheets
  3. Add the following to app/assets/application.css
    *= require bootstrap
  4. Add fonts to vendor/assets/fonts folder
  5. Add this to config/initializers/assets.rb
    config.assets.paths << "#{Rails}/vendor/assets/fonts" Rails.application.config.assets.precompile << /.(?:svg|eot|woff|woff2|ttf)\z/
  6. Create new stylesheet named bootstrap_override.css.erb and add the following
  @font-face {
    font-family: 'Glyphicons Halflings';
    src: url(<%= asset_path('glyphicons-halflings-regular.eot').to_s %>);
    src: url(<%= asset_path('glyphicons-halflings-regular.eot?#iefix').to_s %>) format('embedded-opentype'), 
         url(<%= asset_path('glyphicons-halflings-regular.woff').to_s %>) format('woff'),
         url(<%= asset_path('glyphicons-halflings-regular.woff2').to_s %>) format('woff2'),
         url(<%= asset_path('glyphicons-halflings-regular.ttf').to_s %>) format('truetype'), 
         url(<%= asset_path('glyphicons-halflings-regular.svg#glyphicons_halflingsregular').to_s %>) format('svg');
  }
  • Add the following to app/assets/application.css
    *= require bootstrap_override
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment