I\'m new in Rails and apologize if that is a stupid question. But i cannot resolve my problem: I added Bootstrap to my new app but it still doesn\'t use any new styles.
I suspect you have an older version of bootstrap in your environment. Try updating your Gemfile with gem 'bootstrap-sass', '3.3.3'
and running bundle
. Make sure to restart your server after the update.
Alternatively, you can just run bundle update
.
After several hours i've found a problem - my pages_controller was incorrect:
class PagesController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
end
instead of:
class PagesController < ApplicationController
def index_page
end
end
Controllers should inherit from main Controller!
P.S:
Adding string layout "application"
to the wrong controller also helped:
class PagesController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
layout "application"
end
But I do not recommend go that way
there is an easier way, I will describe the sequence:
after adding gem 'bootstrap-sass'
doing bundle install
, restart server
than add in config/application.rb
next string:
config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)
for your images, than create custom.css.scss
in app/assets/stylesheets
and add there @import "bootstrap";
,
in your custom.css.scss
you can write your own styles