FreddieE FreddieE - 2 years ago 128
Ruby Question

Bootstrap styling not being applied to Rails page

I'm new to Rails, so have been following an online video tutorial building a project.

I've been trying to add Bootstrap, but even after

  1. Adding the Gem,

  2. Doing a bundle install,

  3. Restarting the mysql server, and

  4. Adding the scss @bootsrap import to the application.css.scss file,

It's still not pulling though to my index page.

Is there something I'm missing?

Here's my application.css.scss

* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*= require_self
// Custom bootstrap variables must be set or imported before bootstrap itself.
@import "bootstrap-sprockets";
@import "bootstrap";

Here's my gem file:

source ''

gem 'rails', '4.2.6'
gem 'sqlite3'
gem 'simple_form', '>= 3.2.1'
gem 'bootstrap-sass', '~> 3.3.6'
gem 'sass-rails', '>= 3.2'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc

group :development, :test do
gem 'byebug'

group :development do
gem 'web-console', '~> 2.0'

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]


Answer Source

Please add in your application.html.erb

<%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>

And add in your application.css

@import "bootstrap-sprockets";
@import "bootstrap";
@import 'bootstrap/theme';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download