要导入的文件未找到或不可读:bootstrap-sprockets

时间:2015-03-07 19:59:34

标签: ruby-on-rails twitter-bootstrap ruby-on-rails-4

我正在尝试将bootstrap安装到我的应用程序中,并且遇到各种各样的问题。我已粘贴我的gemfile,application.js和错误代码。我不确定我在这里做错了什么,非常感谢任何帮助。

styles.css.scss

// "bootstrap-sprockets" must be imported before "bootstrap" and "bootstrap/variables"
@import "bootstrap-sprockets";
@import "bootstrap";

宝石文件

source 'http://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.8'
# Use sqlite3 as the database for Active Record
group :development do
  gem 'sqlite3'
  gem 'capistrano'
end

group :production do
  gem 'pg'
  gem 'mysql2'
  gem 'activerecord-mysql-adapter'
end

# Use SCSS for stylesheets
group :assets do
  gem 'coffee-rails'
  gem 'bootstrap-sass', '~> 3.3.3'
  gem 'sass-rails', '>= 3.2'

end
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views



# 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',          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]

的application.js

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
//= require bootstrap-sprockets

这是我的错误

WARN: tilt autoloading 'sass' in a non thread-safe way; explicit require 'sass' suggested.
Completed 500 Internal Server Error in 722ms

ActionView::Template::Error (File to import not found or unreadable: bootstrap-sprockets.
Load paths:
  C:/Sites/jeepjig/app/assets/images
  C:/Sites/jeepjig/app/assets/javascripts
  C:/Sites/jeepjig/app/assets/stylesheets
  C:/Sites/jeepjig/vendor/assets/javascripts
  C:/Sites/jeepjig/vendor/assets/stylesheets
  C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/turbolinks-2.5.2/lib/assets/javascripts
  C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/jquery-rails-3.1.2/vendor/assets/javascripts
  (in C:/Sites/jeepjig/app/assets/stylesheets/styles.css.scss:2)):
    3: <head>
    4:  <%= tag :meta, name: "viewport", content: "width=device-width, initial-scale=1.0" %>
    5:   <title>JeepJig</title>
    6:   <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
    7:   <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
    8:   <%= csrf_meta_tags %>
    9:
  app/assets/stylesheets/styles.css.scss:2
  app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb__1034748832_48995988'


  Rendered C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/templ
ates/rescues/_trace.html.erb (3.0ms)
  Rendered C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/templ
ates/rescues/_request_and_response.html.erb (2.0ms)
  Rendered C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/templ
ates/rescues/template_error.html.erb within rescues/layout (53.0ms)

3 个答案:

答案 0 :(得分:2)

更新:

我删除了

group :assets do

现在我不再收到错误了。 我猜这是在R4中贬值

答案 1 :(得分:2)

我找到了这个链接,很快意识到我遇到了这个问题,因为我已经安装了boostrap-sass,并且在没有重新启动rails服务器的情况下完成了捆绑安装。

我希望提供此信息,以提醒任何其他人找到他们的方式并且无法理解为什么它不起作用。

答案 2 :(得分:0)

删除组:Gemfile中的资产,同时指定

gem 'bootstrap-sass', :git => 'https://github.com/twbs/bootstrap-sass.git', :branch => 'next'
# Use SCSS for stylesheets 
gem 'sass-rails', '~> 5.0' 
gem 'autoprefixer-rails'