How to install jQuery on rails 3.1

I assumed that it is 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 are my dummy rails application , but there is no jQuery in the source, and the delete link does not work ... any ideas that are missing

+5
source share
5 answers

Check out this Railscast . You can check the file application.jsand make sure that it contains the following statement.

//= require jquery
//= require jquery_ujs
+14
source

-urj Gemfile, jquery.js query_ujs.js:

rails generate jquery:install

jquery.js .

"commented out" application.js, :

//= require jquery
//= require jquery_ujs

. , jquery jquery_urj. , js application.js.

+4

, jquery /, /.

app/assets , .

lib/assets - , .

/ , , jquery.

+1
0
source

Just download a copy of jQuery from here: http://code.jquery.com/jquery-1.6.2.js

Then copy the jquery-1.6.2.js file to your <> / public / javascripts folder .

Then, in your application.html.erb file in your layout, include the jquery file before including the application.js file, as shown below:

<%= javascript_include_tag 'jquery-1.6.2', 'application' %>

Then you are good to go.

0
source

All Articles