简体   繁体   English

Bootstrap-sass gem Javascript无法在Rails 4中运行

[英]Bootstrap-sass gem Javascript not Working in Rails 4

when using the bootstrap-sass gem i have loaded my css files properly, however have been receiving an error when i try loading the javascript files. 当使用bootstrap-sass gem时,我已经正确加载了CSS文件,但是在尝试加载javascript文件时却收到错误消息。 I have followed the procedure of loading javascript from https://github.com/twbs/bootstrap-sass however when I view my webpage on localhost 我已经按照从https://github.com/twbs/bootstrap-sass加载javascript的过程进行了操作,但是当我在本地主机上查看网页时

I receive the error "couldn't find file 'bootstrap'" 我收到错误消息“找不到文件'bootstrap'”

This is what my application.js file looks like - Any help would be much appreciated! 这就是我的application.js文件的样子-任何帮助将不胜感激!
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 . 

From the Rails 4 the :assets group isn't used anymore , please remove the group from Gemfile : Rails 4 中不再使用:assets ,请从Gemfile中删除该组:

Rails 4.0 removed the assets group from Gemfile. Rails 4.0从Gemfile中删除了资产组。 You'd need to remove that line from your Gemfile when upgrading. 升级时,您需要从Gemfile中删除该行。 You should also update your application file (in config/application.rb): 您还应该更新您的应用程序文件(在config / application.rb中):

Bundler.require(:default, Rails.env) Bundler.require(:默认,Rails.env)

I got it to work by removing gem 'bootstrap-sass', '~> 3.0.3.0' out of the assets group in gemfile! 我通过从gemfile的资产组中删除gem'bootstrap-sass','〜> 3.0.3.0'使其工作! YAY 好极了

您是否bundle install并确保要从资产管道加载application.js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM