jQuery with Rails

On September 26, 2011, in Ruby on Rails, by admin

If you encounter same problem i have mine where :confirm does not work in:

<%= link_to “Delete”,  location, ;confirm => “Are you sure?” %>

Solution:

1) Grab the jQuery driver at http://github.com/rails/jquery-ujs and put it in your javascripts directory. The file is at src/rails.js

2) Put these codes to your layout file:

= javascript_include_tag “http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js”
= javascript_include_tag ‘rails’

3) to authenticate ajax request from CSRF attack add this to your header :

<%= csrf_meta_tag %>

More information at: http://joshhuckabee.com/jquery-rails-3

Enjoy! :)

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>