jQuery failure in javascript_include_tag during migration to Rails 3.1
I am trying to migrate an application from Rails 3 to 3.1 and having problems with jQuery. The error is bellow. If I remove 'javascript_include_tag "application"' all works fine (with no javascript), so something javascript-related is missing.
Showing C:/.../app/views/layouts/application.html.erb where line #7 raised:
couldn't find file 'jquery'
(in C:/.../app/assets/javascripts/application.js:7)
Extracted source (around line #7):
4: <title><%= @title unless @title.开发者_Go百科blank? %></title>
5: <!-- %= render 'layouts/stylesheets' % -->
6: <%= stylesheet_link_tag "application" %>
7: <%= javascript_include_tag "application", :debug => true %>
8: <%= csrf_meta_tags %>
9: </head>
10: <body>
In my Gemfile I have the entry for jquery-rails:
source 'http://rubygems.org'
gem 'rails', '3.1.0'
gem 'jquery-rails'
....
In application.js:
// This is a manifest file .......
//
//= require jquery
//= require jquery_ujs
//= require_tree .
//
As far as I know that it is the only requirement for working with jQuery in Rails 3.1.
What am I missing?
//= require jquery
Is a new directive in Rails 3.1, which mentions the jquery.js file required.
In Rails 3.1, the jquery.js and jquery_ujs.js files are located inside the vendor/assets/javascripts directory contained within the jquery-rails gem.
Also, did you do a bundle install ?
More about the asset pipeline at http://guides.rubyonrails.org/asset_pipeline.html. More about using Javascript in Rails at http://guides.rubyonrails.org/asset_pipeline.html#manifest-files-and-directives.
精彩评论