2

This is the error I am now getting:

Started GET "/" for 127.0.0.1 at 2014-08-29 06:37:21 -0500
  ActiveRecord::SchemaMigration Load (0.9ms)  SELECT "schema_migrations".* FROM "schema_migrations"
Processing by PostsController#index as HTML
  Post Load (0.8ms)  SELECT "posts".* FROM "posts"   ORDER BY created_at desc
  Rendered shared/_color.html.erb (0.6ms)
  Rendered shared/_color.html.erb (0.1ms)
  Rendered shared/_color.html.erb (0.3ms)
  Rendered posts/index.html.erb within layouts/application (47.4ms)
Completed 500 Internal Server Error in 264ms

Sprockets::FileNotFound - couldn't find file 'jquery'
  (in /app/assets/javascripts/application.js:13):

This is my application.js,

//= require jquery    <--- This is Line 13
//= require jquery_ujs
//= require jquery-ui
//= require jquery.turbolinks
//= require bootstrap
//= require social-share-button
//= require turbolinks
//= require_tree .

This is my Gemfile:

source 'https://rubygems.org'

gem 'rails', '4.1.1'

group :assets do
  gem 'sass-rails', '~> 4.0.3'
  gem 'uglifier', '>= 1.3.0'
  gem 'coffee-rails', '~> 4.0.0'
  gem "font-awesome-rails"
  gem 'bootstrap-sass', '~> 3.2.0'
  gem 'autoprefixer-rails'
  gem 'jquery-rails'
  gem 'jquery-turbolinks'  
  gem 'turbolinks'
end

group :development do
    gem 'annotate', github: 'ctran/annotate_models'
    gem 'sextant'
  gem "quiet_assets", ">= 1.0.2"
  gem 'better_errors', '~> 1.1.0'
  gem 'binding_of_caller', '~> 0.7.2'
    gem 'meta_request'
    gem 'execjs'
    gem 'therubyracer'  
  gem "letter_opener"
  gem 'bullet'   
  gem 'rack-mini-profiler'     
  gem 'guard-rails'
  gem 'rb-fchange', :require => false
  gem 'rb-fsevent', :require => false
  gem 'rb-inotify', :require => false
  gem 'guard-livereload', '~> 2.3.0', :require => false
  gem 'rack-livereload', '~> 0.3.15'
  gem 'spring'
end

group :production do
  gem 'rails_12factor'
end

gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0',          group: :doc
gem 'devise', '~> 3.2.4'
gem 'thin'
gem 'pg'
gem 'cancancan', '~> 1.8.2'
gem 'rolify'
gem 'rmagick', :require => 'RMagick'
gem "mini_magick"
gem 'carrierwave', '~> 0.10.0'
gem "fog", "~> 1.3.1"
gem 'figaro', '~> 0.7.0'
gem 'geocoder', '~> 1.2.2'
gem 'social-share-button', '~> 0.1.6'
gem 'ancestry', '~> 2.1.0'
gem "simple_form"

This is my application.html.erb:

<!DOCTYPE html>
<html>
<head>
  <title>My Site</title>
  <!-- Style sheet -->
    <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>

  <!-- Javascript -->
    <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
  <!-- Fonts -->
    <link href="http://fonts.googleapis.com/css?family=Source+Sans+Pro%3A400%2C400italic%2C700" rel="stylesheet">
    <link href="http://fonts.googleapis.com/css?family=Varela+Round" rel="stylesheet">

  <!-- MISC -->
  <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
  <%= csrf_meta_tags %>
  <%= yield :head %>
</head>
<body>

<%= render partial: "shared/nav" %>
  <% if notice %> <div class="alert alert-info"> <%= notice %> </div> <% end %>
  <% if alert %> <div class="alert alert-warning"> <%= alert %> </div> <% end %>
<%= yield %>

</body>
</html>

What could be causing this error?

marcamillion
  • 32,933
  • 55
  • 189
  • 380
  • Try remove `gem 'jquery-rails'` from assets block it may create issue.` – Dipak Gupta Aug 29 '14 at 11:57
  • @marcamillion I sincerely apologize, for I accidentally hit the 'down vote' button on the question. The suggested workaround for me to correct it and enable the 'up vote' button is for you to make some trivial edit to your post so I can undo my error. I'd like to give you credit for the question, rather than a negative hit. Thank you, and my apologies! – BJ Miller Aug 15 '16 at 17:36

3 Answers3

6

There is no assets group in Gemfile in Rails 4. Remove all your assets gems from that group.

http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#upgrading-from-rails-3-2-to-rails-4-0-gemfile

Peter Tretyakov
  • 3,380
  • 6
  • 38
  • 54
1

You're using rail > 4, so that jquery is included by default without adding a gem into it.

The same goes for jquery-uj and so on.

Also, I've noticed that you're using jquery-turbolinks gem.

According to the GitHub page, you should create your application.js in the following order:

//= require jquery
//= require jquery.turbolinks
//= require jquery_ujs
//
// ... your other scripts here ...
//
//= require turbolinks

and your order is different...

cyber101
  • 899
  • 1
  • 9
  • 19
  • I tried removing the `jquery-rails` gem and it doesn't work. It complains about the `require jquery` in the application.js. – marcamillion Aug 29 '14 at 12:28
1

In your Javascripts folder within assests, the bottom of the page will look like this...

'//=require jquery'
'//=require jquery_ujs'
'//=require turbolinks'
'//=require_tree .'

In my case, i do not have any jquery in my site so i took the "=" out and this fixed my problem! looks beautiful i might add!

'// require jquery'
'// require jquery_ujs'
'// require turbolinks'
'// require_tree .'

Thanks Chris Dunphy