rails / jquery-rails

A gem to automate using jQuery with Rails
MIT License
948 stars 406 forks source link

couldn't find file 'jquery' #180

Closed tdtadeu closed 9 years ago

tdtadeu commented 9 years ago

I'm trying to update the gem in a project using Rails 4.2.0.beta4, but it seems that the jquery file can't be found. I tried changing the jquery-rails version back to 3.1.2 and it works with that version, the problem does seem to be with the current version.

Playing a little in the console I found when you try to require the gem (4.0) it gives you an error, while requiring the 3.1.2 only returns false.

The error in the title happens in the <%= javascript_include_tag "application" %> line of the application layout, of course.

Here's the application.js:

//= require jquery
//= require jquery_ujs
//= require bootstrap-sprockets
//= require bootstrap
//= require slick
//= require_tree .

Gemfile, in case you need it:

source "https://rubygems.org"

ruby "2.1.4"

gem "rails", "~> 4.2.0.beta4"
gem "pg"
gem "sass-rails", "~> 5.0.0.beta1"
gem "bootstrap-sass"
gem "uglifier", ">= 1.3.0"
gem "coffee-rails", "~> 4.0.0"
gem "therubyracer",  platforms: :ruby
gem "draper", "~> 1.3"
gem "simple_form", github: "plataformatec/simple_form"
gem "dotenv-rails"
gem "devise"
gem "dynamic_form"
gem "chosen-rails"

group :assets do
  gem "asset_sync"
end

gem "jquery-rails"
gem "jbuilder", "~> 2.0"

group :development do
  gem "quiet_assets"
  gem "rspec-rails"
end

group :test, :development do
  gem "did_you_mean"
end

group :test do
  gem "capybara"
  gem "poltergeist"
  gem "simplecov", "~> 0.7.1"
  gem "factory_girl_rails"
  gem "database_cleaner"
  gem "shoulda-matchers", require: false
  gem "capybara-email"
end
rafaelfranca commented 9 years ago

Have you tried with 4.2.0.rc2?

rafaelfranca commented 9 years ago

I create a new application and it is working fine. It seems to be something related to your setup.

smidwap commented 9 years ago

I ran into the same problem. I ran rails _4.2.0rc2_ new jquery_rails_test and checked Gemfile.lock to make sure I was running jquery-rails 4.0.0. Then I created a scaffold bin/rails g scaffold posts, started the rails server, and went to localhost:3000/posts. Then I got:

couldn't find file 'jquery'
  (in /Users/smidwap/development/jquery_test/app/assets/javascripts/application.js:13)

I downgraded to jquery-rails 3.0.2, and the problem went away.

I also tried upgrading an existing app to rails 4.2.0rc2. I didn't run into any issues, since my jquery-rails version had been locked at 3.0.2. Sure enough, when I upgraded jquery-rails to 4.0.0, the error came back.

smidwap commented 9 years ago

Figured it out. It was a permissions problem. I ran chown where jquery-rails 4.0.0 is installed (/Library/Ruby/Gems/2.0.0/gems/jquery-rails-4.0.0) to change the owner from root to my local mac username. I restarted my Rails server, and jquery is now found.

Interestingly, root is the owner of my local jquery-rails-3.0.2 directory. I'm not sure what changed in 4.0.0 that made root no longer work. Maybe the removal of action_view/railtie?