# Firebug jQuery undefined message in rails app

**URL:** <https://www.ruby-forum.com/t/firebug-jquery-undefined-message-in-rails-app/190135>\
**Category:** Rails\
**Created:** [June 16, 2010, 7:00pm UTC](https://www.ruby-forum.com/t/firebug-jquery-undefined-message-in-rails-app/190135 "2010-06-16T19:00:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmaenpaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de053/32.png) [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Post date:** [June 16, 2010, 7:00pm UTC](https://www.ruby-forum.com/t/firebug-jquery-undefined-message-in-rails-app/190135/1 "2010-06-16T19:00:03Z")

</div>

In rails app, I add the following line of code in application.js and I  
get jQuery is not defined in firebug console.  
In application.html.erb, I have the following:

and I installed jquery in public/javascripts

Any ideas what’s going wrong? thanks for reply.

(function($) {

```
var linksToInt = {
    "#pple": 0,
    "#serv": 1,
    "#sol": 2,
    "#dash": 3,
    "#adm": 4,
    "#inv": 5,
    "#stu": 6

}

/*
links = document.getElementsByTagName("a");
if(links.className.indexOf("div-link") > -1){
    links.onclick = function{

```

removeHash(this.getAttribute(“href”));};  
}  
\*/

```
$("a.div-link").click(function(){displayDiv($(this).attr("href"));});

function displayDiv(id){
var linkInt = linksToInt[id];
on_btn_click(linkInt);
}

function on_btn_click(displayDiv){
    displayDiv != null ? null : this;

    switch(displayDiv){
        case 0:
            $(content).empty();
            $(displayDiv).show();
            break;
        case 1:
            $(content).empty();
            $(displayDiv).show();
            break;
        case 2:
            $(content).empty();
            $(displayDiv).show();
            break;
        case 3:
            $(content).empty();
            $(displayDiv).show();
            break;
        case 4:
            $(content).empty();
            $(displayDiv).show();
            break;
        case 5:
            $(content).empty();
            $(displayDiv).show();
            break;
        case 6:
            $(content).empty();
            $(displayDiv).show();
            break;
    }
}

```

})(jQuery);

---

<div class="post-metadata">

**Author:** ![jmaenpaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de053/32.png) [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Post date:** [June 16, 2010, 7:41pm UTC](https://www.ruby-forum.com/t/firebug-jquery-undefined-message-in-rails-app/190135/2 "2010-06-16T19:41:55Z")

</div>

Does anyone have a step by step instruction on how to remove prototype  
completely so jQuery works? The jRails plugin seems to make them work  
together. I want to remove prototype as I will never use it.  
Thanks

---

<div class="post-metadata">

**Author:** ![jmaenpaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de053/32.png) [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Post date:** [June 16, 2010, 8:02pm UTC](https://www.ruby-forum.com/t/firebug-jquery-undefined-message-in-rails-app/190135/3 "2010-06-16T20:02:40Z")

</div>

Actually stepcarousel.js which uses jquery is working in the application  
so I don’t think there is a conflict with prototype. However I still get  
the error jquery is undefined.

---

<div class="post-metadata">

**Author:** ![jmaenpaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de053/32.png) [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Post date:** [June 16, 2010, 9:27pm UTC](https://www.ruby-forum.com/t/firebug-jquery-undefined-message-in-rails-app/190135/4 "2010-06-16T21:27:01Z")

</div>

First, try:

“”

Instead of

“”

Else:

“javascript\_include\_tag :all”

You can set :recursive =\> true if you want Rails to search all  
subdirectories of public/javascripts.

---

<div class="post-metadata">

**Author:** ![jmaenpaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de053/32.png) [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Post date:** [June 16, 2010, 8:48pm UTC](https://www.ruby-forum.com/t/firebug-jquery-undefined-message-in-rails-app/190135/5 "2010-06-16T20:48:54Z")

</div>

John M. wrote:

> Does anyone have a step by step instruction on how to remove prototype  
> completely so jQuery works?

Sure:

1. Remove public/javascripts/prototype.js.
2. There is no step 2.

> The jRails plugin seems to make them work  
> together. I want to remove prototype as I will never use it.

Perhaps unwise. After some experimentation with both, I’m include to  
believe that Prototype may be the better of the two. I want to play  
with both a little more before I state that as fact, though.

> Thanks

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
