在Rails项目中找不到文件'jquery' [英] couldn't find file 'jquery' in Rails project
问题描述
我正在通过Rails 3.2.13和Ruby 2.0.0的Agile Web Development书籍,但是当试图访问 localhost:3000 $ c $时,我总是收到以下错误
$ 存储#索引中的Sprockets :: FileNotFound
找不到文件'jquery'(在/ Users /.../ app / assets / javascripts / application.js中:13)
$ b
我的 application.js
file:
//这是一个将被编译到application.js中的清单文件,它将包含下面列出的所有文件
//。
//
// ...
//
// =要求jquery
// =要求jquery-ui
// =要求jquery_ujs
// = require_tree。
在我的 Gemfile
中,我有 gem'jquery-rails','〜> 2.3.0'
并试图找到许多不同的解决方案,我在互联网上找不到任何解决方案。
>我得到它的工作。
- 把
gem'jquery-rails',〜> 2.3.0
转换为Gemfile。 - 在终端中输入
rm Gemfile.lock
来移除Gemfile.lock。 / li>
- 从终端运行
bundle install
确保// = require jquery-ui
在application.js中
注意:如果第3步不起作用,然后通过终端运行 sudo gem install jquery-rails -v 2.3.0
。
I'm working through the Agile Web Development book with Rails version 3.2.13 and Ruby 2.0.0, but I keep getting the following error when trying to access localhost:3000
:
Sprockets::FileNotFound in Store#index
couldn't find file 'jquery' (in /Users/.../app/assets/javascripts/application.js:13)
My application.js
file:
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// ...
//
//= require jquery
//= require jquery-ui
//= require jquery_ujs
//= require_tree .
In my Gemfile
, I have gem 'jquery-rails', '~> 2.3.0'
and have attempted many different solutions I found on the internet to no avail.
I got it to work.
- Put
gem 'jquery-rails', "~> 2.3.0"
into Gemfile. - Remove Gemfile.lock by typing
rm Gemfile.lock
into the terminal. - Run
bundle install
from the terminal - Make sure
//= require jquery-ui
is in application.js
Note: If step 3 doesn't work, then run sudo gem install jquery-rails -v 2.3.0
through the terminal.
这篇关于在Rails项目中找不到文件'jquery'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!