Reputation: 44066
I assumed it was already installed but in my gemfile i have
gem "jquery-rails"
but in the asset/javascripts folder i have
accounts.js.coffee
application.js
which are both commented out
Here is my dummy rails application but in the source there is no jQuery and the delete link doesnt work...any ideas whats missing
Upvotes: 5
Views: 8732
Reputation: 10874
Besides adding query-urj in you Gemfile, you also need to run this to generate jquery.js and query_ujs.js:
rails generate jquery:install
This will install jquery.js for you.
As for the 'commented out' application.js, if it has these lines:
//= require jquery
//= require jquery_ujs
Then you're ready to go. They are not just comments, they actually tell the pipeline to use jquery and jquery_urj. When you app runs, both js files will be merged into application.js.
Upvotes: 4
Reputation: 1787
As far as I guess, jquery is not located at app/assets, but vendor/assets.
app/assets refers to your assets you need for this particular app.
lib/assets is for assets you share across multiple applications.
vendor/assets is for assets not maintained by you, like jquery.
Upvotes: 1
Reputation: 2341
Just download a copy of jQuery from here :http://code.jquery.com/jquery-1.6.2.js
Then copy the file jquery-1.6.2.js into your folder <>/public/javascripts.
Then, in your application.html.erb file in your layout, include the jquery file before you include the application.js file, as shown below:
<%= javascript_include_tag 'jquery-1.6.2', 'application' %>
Then you are good to go.
Upvotes: 0
Reputation: 176342
Have a look at this Railscast. You might want to check the application.js
file and make sure it contains the following statement.
//= require jquery
//= require jquery_ujs
Upvotes: 14
Reputation: 84140
JQuery is the default in rails 3.1. It comes from the jquery-rails gem.
The comments in application.js are actually used by the asset pipeline to combine your assets and serve them as a single file.
http://blog.nodeta.com/2011/06/14/rails-3-1-asset-pipeline-in-the-real-world/
Upvotes: 0