Bootstrap-sass gem Javascript无法在Rails中工作4

时间:2014-01-28 18:17:55

标签: javascript ruby-on-rails ruby twitter-bootstrap sass

当使用bootstrap-sass gem我已正确加载我的css文件时,但是当我尝试加载javascript文件时收到错误。我已经按照从https://github.com/twbs/bootstrap-sass加载javascript的过程,但是当我在localhost上查看我的网页时

我收到错误“找不到文件'bootstrap'”

这是我的application.js文件的样子 - 任何帮助将不胜感激!
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
// Loads all Bootstrap javascripts
//= require bootstrap
//= require_tree .

3 个答案:

答案 0 :(得分:3)

Rails 4 :assets group isn't used anymore,请从 Gemfile 中删除该群组:

  

Rails 4.0从Gemfile中删除了资产组。升级时,您需要从Gemfile中删除该行。您还应该更新您的应用程序文件(在config / application.rb中):

     
    

Bundler.require(:default,Rails.env)

  

答案 1 :(得分:1)

我通过移除gem'bootstrap-sass','〜>来实现它。 3.0.3.0'在gemfile中的资产组中! YAY

答案 2 :(得分:0)

您是否bundle install并确保加载application.js(来自资产管道)。