I've been learning Ruby on Rails for the last few days and i'm following tutorials from a book. I'm working on an app which requires importing bootstrap however i'm having trouble installing it into my project.
I'm using Ruby version 2.3.1 and Rails version 5.1.1 and i'm using the cloud9 coding environment
I create a new app with the following command:
rails new bootstrap_app
The next instruction is to "add the bootstrap gem to the gemfile" with the following command:
gem 'bootstrap‐sass' , '~> 3.3.6'
I do this and I get the following error:
ERROR: While executing gem ... (Gem::CommandLineError)
Unknown command bootstrap-sass,
I looked up this error and I found it on stackoverflow here however "restarting the server" didn't work in my case.
The next instruction in the tutorial, is the command
bundle install
I do this and it tells me a list of dependencies that are installed (bootstrap is not listed)
I tried the command gem install bootstrap-sass
and it said it installed the gem successfully however when i try to import bootstrap in my CSS file as follows:
@import "bootstrap‐sprockets" ;
@import "bootstrap";
i get the following error:
ActionController::RoutingError (No route matches [GET] "/assets/bootstrap%E2%80%90sprockets"):
any ideas on how i can get this working? Thanks
As CD-RUM stated, you will need to add both the gem bootstrap-sass
& gem sass-rails
in to your Gemfile. I would also suggest adding gem 'sprockets', '2.11.0'
as well since the newer version of sprockets that comes with rails 5 has had some issues working well with Bootstrap. Then run bundle install
.
You will also want to rename your application.css
file to application.scss
and add the import files (@import "bootstrap-sprockets"
& @import "bootstrap"
) there . Now restart your server.
Read through the Ruby on Rails installation instructions here: bootsrap-sass gem & if you're still having issues consider changing the version of the bootstrap-sass gem to an earlier version (I use gem 'bootstrap-sass', '~> 3.3.5.1'
) since some people seem to experience version conflicts.