Search code examples
ruby-on-railstwitter-bootstraptwitter-bootstrap-rails

Twitter-bootstrap-rails: does it install Bootstrap into a project?


I do everything according to Readme but having an issue when starting a rails app: Sprockets::FileNotFound And it points to //= require twitter/bootstrap Does this gem really install bootstrap stylesheets and corresponding js libraries or one is supposed to install them manually (with bower or in another way)? Here is my Gemfile:

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5.1'
# Use postgresql as the database for Active Record
gem 'pg', '~> 0.15'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :assets do
  gem 'twitter-bootstrap-rails'
end

gem 'responders', '~> 2.1.1'
gem 'haml'

group :development, :test do
  gem 'pry-byebug'
  gem 'pry-rails'
  gem 'rspec-expectations', '~> 3.0.0'
  gem 'spring-commands-rspec'
  #gem 'guard-rspec', require: false
  gem 'rspec-rails', '~> 3.0.0'
  # Support for its syntax
  gem 'rspec-its', '~> 1.0.1'
  gem 'shoulda-matchers', '~> 3.1.1'
  gem 'factory_girl_rails'
  gem 'ffaker'
  gem "bower-rails", "~> 0.10.0"
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'
  gem 'haml-rails'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

Solution

  • I'd say that because group assets were dropped in Rails 4. From the docs:

    Rails 4.0 removed the assets group from Gemfile. You'd need to remove that line from your Gemfile when upgrading. You should also update your application file (in config/application.rb):

    So instead of using it

    ....
    # Use Capistrano for deployment
    # gem 'capistrano-rails', group: :development
    group :assets do
      gem 'twitter-bootstrap-rails'
    end
    ....
    

    Just remove the group block:

    ....
    # Use Capistrano for deployment
    # gem 'capistrano-rails', group: :development
    gem 'twitter-bootstrap-rails'
    ....
    

    And then run bundle install and restart the server.

    More info - Why did Rails4 drop support for “assets” group in the Gemfile