我正在尝试在Rails上安装Bootstrap,但似乎无法安装它。我已经运行bundle install
,bundle update
和rails server
,但似乎无法让它发挥作用。
以下是错误代码:
要导入的文件未找到或不可读:bootstrap 加载路径:
C:/用户/ teddynuts /桌面/ pinteresting /应用/资产/图片 C:/用户/ teddynuts /桌面/ pinteresting /应用/资产/ JavaScript的 C:/用户/ teddynuts /桌面/ pinteresting /应用/资产/样式表 C:/用户/ teddynuts /桌面/ pinteresting /供应商/资产/ JavaScript的 C:/用户/ teddynuts /桌面/ pinteresting /供应商/资产/样式表 c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/turbolinks-2.2.2/lib/assets/javascripts c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0 /gems/jquery-rails-3.1.0/vendor/assets/javascripts C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/coffee-rails-4.0.1/lib/assets/javascripts
(在c:/Users/teddynuts/Desktop/pinteresting/app/assets/stylesheets/bootstrap_and_customization.css.scss:1)
我的标题为bootstrap_and_customization.css.scss
代码的CSS文件是:
@import "bootstrap";
我的Gem文件代码是:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# 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'
gem 'bootstrap-sass',
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
# Use debugger
# gem 'debugger', group: [:development, :test]
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin]
答案 0 :(得分:0)
您需要为您的"组"分配一些内容。什么进入group :doc
?
我看到你正在参加One Month Rails教程,所以课程(直到bootstrap)的gemfile应该是这样的:
source 'https://rubygems.org'
gem 'rails', '4.1.0'
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jquery-turbolinks'
gem 'jbuilder', '~> 1.2'
gem 'bootstrap-sass', '~> 3.1.1'
# Gems for Local Development
group :development, :test do
gem 'sqlite3'
end
# Gems for Heroku
group :production do
gem 'pg'
gem 'rails_12factor'
end
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
Official Sass port of Bootstrap
有时当你被困时,只需给Official Repo看看。
答案 1 :(得分:0)
问题在于:
gem 'bootstrap-sass',
group: :doc
这可能不是很明显,但它是一个语句。事实上,它的解释如下:
gem 'bootstrap-sass', { :group => :doc }
...因此指定的gem仅在文档生成期间可用。这个问题的解决方案是用以下内容替换上述内容:
gem 'bootstrap-sass'
但是,由于您使用的是Windows(如果它是x64,很可能),您可能会遇到其他问题,例如this one。
答案 2 :(得分:0)
尝试使用bootstrap-sass-rails。它适用于资产管道。 https://github.com/yabawock/bootstrap-sass-rails