简体   繁体   中英

Ruby on Rails - Uncaught ReferenceError: $ is not defined

I am using Rails 3.2.13, I have cloned one project from git repo. CSS styles are working fine. But whole javascript plugins are not loading. In console I am getting some Javascript errors like below,

Uncaught SyntaxError: Unexpected token ILLEGAL
Uncaught ReferenceError: $ is not defined
Uncaught ReferenceError: $ is not defined
Uncaught ReferenceError: jQuery is not defined

In application.js,

//= require jquery
//= require jquery_ujs
//= require_tree .

Even after precompile also it is not working. Please help me to solve this issue.

Update : Got into this problem on one of my machines.

Not sure what is the exact root cause of the problem but this a way around to overcome this issue.

  1. Please make sure the below gem is installed.

    gem install sprockets

  2. Run the following command

    rake assets:precompile

To know more about the assets pipeline refer http://asciicasts.com/episodes/279-understanding-the-asset-pipeline

Hope this helps.

i had this exact problem with rails 3.2.1 after upgrading to mavericks on my mac. After researching i updated rails to 3.2.18 which solved the problem. Apparently some versions of sprockets have proplems with the asset pipeline. checkout more info at https://github.com/sstephenson/sprockets/issues/352

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM