Twitter-bootstrap-rails:是否将 Bootstrap 安装到项目中?
Twitter-bootstrap-rails: does it install Bootstrap into a project?
我根据 Readme 做所有事情但是在启动 rails 应用程序时遇到问题:Sprockets::FileNotFound 它指向 //= require twitter/bootstrap
这个 gem 真的安装 bootstrap 样式表和相应的 js 库还是应该手动安装它们(使用 bower 或其他方式)?
这是我的 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
我会这么说是因为 group assets
were dropped in Rails 4。来自文档:
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):
所以不用它
....
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :assets do
gem 'twitter-bootstrap-rails'
end
....
只需删除 group
块:
....
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
gem 'twitter-bootstrap-rails'
....
然后运行bundle install
并重启服务器。
更多信息 - Why did Rails4 drop support for “assets” group in the Gemfile
我根据 Readme 做所有事情但是在启动 rails 应用程序时遇到问题:Sprockets::FileNotFound 它指向 //= require twitter/bootstrap
这个 gem 真的安装 bootstrap 样式表和相应的 js 库还是应该手动安装它们(使用 bower 或其他方式)?
这是我的 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
我会这么说是因为 group assets
were dropped in Rails 4。来自文档:
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):
所以不用它
....
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :assets do
gem 'twitter-bootstrap-rails'
end
....
只需删除 group
块:
....
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
gem 'twitter-bootstrap-rails'
....
然后运行bundle install
并重启服务器。
更多信息 - Why did Rails4 drop support for “assets” group in the Gemfile