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

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

问题描述

我正在使用 Rails 版本 3.2.13 和 Ruby 2.0.0 阅读敏捷 Web 开发一书,但在尝试访问 localhost:3000 时不断收到以下错误:

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

找不到文件jquery"(在/Users/.../app/assets/javascripts/application.js:13)

我的 application.js 文件:

// 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 .

在我的 Gemfile 中,我有 gem 'jquery-rails', '~>2.3.0' 并尝试了我在互联网上找到的许多不同的解决方案,但均无济于事.

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.

推荐答案

我搞定了.

  1. gem 'jquery-rails', "~> 2.3.0" 放入 Gemfile.
  2. 通过在终端中输入 rm Gemfile.lock 来删除 Gemfile.lock.
  3. 从终端运行bundle install
  4. 确保 //= require jquery-ui 在 application.js 中
  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

注意:如果步骤 3 不起作用,则通过终端运行 sudo gem install jquery-rails -v 2.3.0.

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天全站免登陆