【问题标题】:couldn't find file 'jquery' in Rails project在 Rails 项目中找不到文件“jquery”
【发布时间】:2013-06-21 13:46:00
【问题描述】:

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

Sprockets::FileNotFound in Store#index

couldn't find file 'jquery' (in /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' 并尝试了我在互联网上找到的许多不同的解决方案,但均无济于事。

【问题讨论】:

    标签: jquery ruby-on-rails gem


    【解决方案1】:

    我让它工作了。

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

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

    【讨论】:

    • 如果你和我一样,这不起作用:确保你没有安装 gem jrails,它会与 jquery-rails 冲突,不会告诉你任何有用的错误所以。我正在升级到 Rails 3。
    • 还要确保在此步骤之后重新启动 Rails 服务器,之后才对我有用。顺便说一句,谢谢!
    【解决方案2】:

    另外,如果你在 OS X 上使用POW,那么你可能需要restart your app

    touch tmp/restart.txt
    

    【讨论】:

      【解决方案3】:

      这可能很愚蠢,但重新启动服务器对我有用,它会重新收集库。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-02-04
        • 1970-01-01
        • 2021-01-19
        • 2020-06-08
        • 2013-01-31
        相关资源
        最近更新 更多