5

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

1
  • Contents of application.js? Commented Aug 23, 2011 at 21:54

5 Answers 5

14

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
Sign up to request clarification or add additional context in comments.

Comments

4

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.

Comments

1

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.

Comments

0

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/

Comments

0

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.

1 Comment

For each .js file that you want included in your application, follow the same procedure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.