# Couldn't find file 'jquery' rails 3.1 stable mountable engine

**URL:** <https://www.ruby-forum.com/t/couldnt-find-file-jquery-rails-3-1-stable-mountable-engine/211345>\
**Category:** Rails\
**Created:** [September 1, 2011, 9:02pm UTC](https://www.ruby-forum.com/t/couldnt-find-file-jquery-rails-3-1-stable-mountable-engine/211345 "2011-09-01T21:02:21Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [September 1, 2011, 9:02pm UTC](https://www.ruby-forum.com/t/couldnt-find-file-jquery-rails-3-1-stable-mountable-engine/211345/1 "2011-09-01T21:02:21Z")

</div>

When I create a new engine in Rails 3.1 stable and then access the dummy  
app or the engine I get an error say that the app can’t find jquery.

I’ve created the engine using  
rails plugin new coffee --mountable

I’ve also created a basic controller in the engine and the dummy app. If  
I remove the javascript include tag, everything works. But with the tag  
there it just bails since it can’t fine jQuery. The jquery-rails gem is  
installed. I have jquery as a dependency in my  
gemspec file. I’ve even added an Gemfile to the dummy app just to try,  
but it gives the same error.

## accessing the dummy app

Sprockets::FileNotFound in Root#index  
couldn’t find file ‘jquery’  
(in /Webapps/coffee/test/dummy/app/assets/javascripts/application.js:7)

Started GET “/” for 127.0.0.1 at 2011-09-01 20:31:01 +0200  
Processing by RootController#index as HTML  
Rendered root/index.html.erb within layouts/application (8.9ms)  
Completed 500 Internal Server Error in 89ms

ActionView::Template::Error (couldn’t find file ‘jquery’  
(in  
/Webapps/coffee/test/dummy/app/assets/javascripts/application.js:7)):  
3:   
4: Dummy  
5: \<%= stylesheet\_link\_tag “application” %\>  
6: \<%= javascript\_include\_tag “application” %\>  
7: \<%= csrf\_meta\_tags %\>  
8:   
9:   
app/views/layouts/application.html.erb:6:in  
`\_app\_views\_layouts\_application\_html\_erb\_\_\_187280571548804820\_2155822020’

## accessing the engine

Sprockets::FileNotFound in Coffee/pages#index  
couldn’t find file ‘jquery’  
(in /Webapps/coffee/app/assets/javascripts/coffee/application.js:7)

Started GET “/coffee” for 127.0.0.1 at 2011-09-01 20:49:57 +0200  
Processing by Coffee::PagesController#index as HTML  
Rendered /Webapps/coffee/app/views/coffee/pages/index.html.erb within  
layouts/coffee/application (0.3ms)  
Completed 500 Internal Server Error in 41ms

ActionView::Template::Error (couldn’t find file ‘jquery’  
(in  
/Users/jorgen/Webapps/coffee/app/assets/javascripts/coffee/application.js:7)):  
3:   
4: Coffee  
5: \<%= stylesheet\_link\_tag “coffee/application” %\>  
6: \<%= javascript\_include\_tag “coffee/application” %\>  
7: \<%= csrf\_meta\_tags %\>  
8:   
9:

---

<div class="post-metadata">

**Author:** ![coffeepunk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e47774/32.png) [@coffeepunk](https://www.ruby-forum.com/u/coffeepunk)\
**Post date:** [September 2, 2011, 4:04am UTC](https://www.ruby-forum.com/t/couldnt-find-file-jquery-rails-3-1-stable-mountable-engine/211345/2 "2011-09-02T04:04:02Z")

</div>

Hey Jorgen,

This isn’t a solution, but it may be better to simply remove the line  
from your js file (Looks like #= require jquery) and use the Google  
CDN version:

= javascript\_include\_tag  
‘[//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js](https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js)’, :defer  
=\> true, :async =\> true

This will this be faster for your users (because Google has more  
cloudspace than you, probably) and it also removes the need for  
Sprockets to compress it.

I hope you find out what’s going on. 😕

Cheers

On Thu, Sep 1, 2011 at 12:02 PM, Jorgen N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ## gemspec file. I’ve even added an Gemfile to the dummy app just to try, Started GET “/” for 127.0.0.1 at 2011-09-01 20:31:01 +0200 6: \<%= javascript\_include\_tag “application” %\> Sprockets::FileNotFound in Coffee/pages#index ActionView::Template::Error (couldn’t find file ‘jquery’
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> –  
> You received this message because you are subscribed to the Google G. “Ruby  
> on Rails: Talk” group.  
> To post to this group, send email to [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid).  
> To unsubscribe from this group, send email to  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid).  
> For more options, visit this group at  
> [http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

–  
Kurtis Rainbolt-Greene:  
title: “Hacker, Designer, Author, & Father”  
address: “718 Mill Street, Springfield, OR 97477”  
phone: “(202) 643-2263”

---

<div class="post-metadata">

**Author:** ![coffeepunk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e47774/32.png) [@coffeepunk](https://www.ruby-forum.com/u/coffeepunk)\
**Post date:** [September 2, 2011, 8:46am UTC](https://www.ruby-forum.com/t/couldnt-find-file-jquery-rails-3-1-stable-mountable-engine/211345/3 "2011-09-02T08:46:35Z")

</div>

Hi Kurtis,

Thanks for your answer. I was thinking the same thing and I’ll just  
start developing without javascript all together since I don’t need it  
in the initial phase.

I’ve also tried using and creating the engine with Rails 3.1.0rc5 and  
3.1.0rc8 and I get the same error. Surely I can’t be alone with geting  
this error?

I think I’ll post an issue on Github.

---

<div class="post-metadata">

**Author:** ![coffeepunk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e47774/32.png) [@coffeepunk](https://www.ruby-forum.com/u/coffeepunk)\
**Post date:** [September 2, 2011, 8:12pm UTC](https://www.ruby-forum.com/t/couldnt-find-file-jquery-rails-3-1-stable-mountable-engine/211345/4 "2011-09-02T20:12:15Z")

</div>

I thought I would post here very quickly because I was having the same  
problem and utilizing the google cloud resolved the issue. Here is what  
it looks like now.

// This is a manifest file that’ll be compiled into including all the  
files listed below.  
// Add new JavaScript/Coffee code in separate files in this directory  
and they’ll automatically  
// be included in the compiled file accessible from  
[http://example.com/assets/application.js](http://example.com/assets/application.js)  
// It’s not advisable to add code directly here, but if you do, it’ll  
appear at the bottom of the  
// the compiled file.  
//  
//= javascript\_include\_tag  
‘[//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js](https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js)’, :defer  
=\> true, :async =\> true  
//= require jquery\_ujs  
//= require\_tree .

---

<div class="post-metadata">

**Author:** ![coffeepunk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e47774/32.png) [@coffeepunk](https://www.ruby-forum.com/u/coffeepunk)\
**Post date:** [September 12, 2011, 11:12pm UTC](https://www.ruby-forum.com/t/couldnt-find-file-jquery-rails-3-1-stable-mountable-engine/211345/5 "2011-09-12T23:12:23Z")

</div>

I had the same problem and finally fixed.  
The solution is to explicitly require the ‘jquery-rails’ gem in the  
dummy config/application.rb file, so Sprockets can add the jquery  
assets in the assets.path.

In test/dummy/config/application.rb

```
require File.expand_path('../boot', __FILE__ )

# Pick the frameworks you want:
# require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "rails/test_unit/railtie"
require "sprockets/railtie"

# Auto-require default libraries and those for the current Rails

```

environment.  
Bundler.require :default, Rails.env

```
require "coffee"
require "jquery-rails" # this should be auto-included with the

```

Bundler.require :default, Rails.env, but it’s not happening

```
module Dummy
  class Application < Rails::Application
      # ...
  end
end

```

Same with other gems that have assets that should be auto-loaded by  
Sprockets.  
Hope this helps.

- Mario Izquierdo

---

<div class="post-metadata">

**Author:** ![coffeepunk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e47774/32.png) [@coffeepunk](https://www.ruby-forum.com/u/coffeepunk)\
**Post date:** [September 19, 2011, 9:24am UTC](https://www.ruby-forum.com/t/couldnt-find-file-jquery-rails-3-1-stable-mountable-engine/211345/6 "2011-09-19T09:24:03Z")

</div>

The solution for me was to add jquery-rails to my engines Gemfile and  
restart the server.

I would suspect that it does not want adding to the gemspec however,  
however adding it as a development dependency might be okay.

– Kris.

---

<div class="post-metadata">

**Author:** ![coffeepunk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e47774/32.png) [@coffeepunk](https://www.ruby-forum.com/u/coffeepunk)\
**Post date:** [September 22, 2011, 2:00am UTC](https://www.ruby-forum.com/t/couldnt-find-file-jquery-rails-3-1-stable-mountable-engine/211345/7 "2011-09-22T02:00:05Z")

</div>

Fixed here

> <https://github.com/rails/rails/commit/007f56701102647088673d92b165c3d862fbba22>
>
> Closes #3091

---

<div class="post-metadata">

**Author:** ![coffeepunk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e47774/32.png) [@coffeepunk](https://www.ruby-forum.com/u/coffeepunk)\
**Post date:** [September 2, 2011, 9:29am UTC](https://www.ruby-forum.com/t/couldnt-find-file-jquery-rails-3-1-stable-mountable-engine/211345/8 "2011-09-02T09:29:43Z")

</div>

At the very least it could be a good idea to include in the issue:  
It’d be nice to know where Sprockets was looking for the file.

On Thu, Sep 1, 2011 at 11:46 PM, Jorgen N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I think I’ll post an issue on Github.

–  
Kurtis Rainbolt-Greene:  
title: “Hacker, Designer, Author, & Father”  
address: “718 Mill Street, Springfield, OR 97477”  
phone: “(202) 643-2263”

---

<div class="post-metadata">

**Author:** ![coffeepunk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e47774/32.png) [@coffeepunk](https://www.ruby-forum.com/u/coffeepunk)\
**Post date:** [July 22, 2015, 9:22pm UTC](https://www.ruby-forum.com/t/couldnt-find-file-jquery-rails-3-1-stable-mountable-engine/211345/9 "2015-07-22T21:22:47Z")

</div>

tothemario wrote in post #1021529:

> ```
> # Auto-require default libraries and those for the current Rails
> 
> ```
> 
> environment.  
> Bundler.require :default, Rails.env
> 
> ```
> require "coffee"
> require "jquery-rails" # this should be auto-included with the
> 
> ```
> 
> Bundler.require :default, Rails.env, but it’s not happening
> 
> ```
> module Dummy
> class Application < Rails::Application
> # ...
> end
> end
> 
> ```
> 
> Same with other gems that have assets that should be auto-loaded by  
> Sprockets.  
> Hope this helps.
> 
> - Mario Izquierdo

This solved my problem, I gotta login to thank you!
