在Rails项目中找不到文件'jquery' [英] couldn't find file 'jquery' in Rails project

查看:161
本文介绍了在Rails项目中找不到文件'jquery'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过Rails 3.2.13和Ruby 2.0.0的Agile Web Development书籍,但是当试图访问 localhost:3000
$ 存储#索引中的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'并试图找到许多不同的解决方案,我在互联网上找不到任何解决方案。

>我得到它的工作。


  1. gem'jquery-rails',〜> 2.3.0 转换为Gemfile。

  2. 在终端中输入 rm Gemfile.lock 来移除Gemfile.lock。 / li>
  3. 从终端运行 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.

  1. Put gem 'jquery-rails', "~> 2.3.0" into Gemfile.
  2. Remove Gemfile.lock by typing rm Gemfile.lock into the terminal.
  3. Run bundle install from the terminal
  4. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆