I am testing creating a link_to with :remote=> true to get the ajax remote link handling.
<%= link_to "Get Books", "/books", :remote=> true %>
The helper for rails3 resolves the code correctly in the view and I get as source:
<a href="/books" data-remote="true">Get Books</a>
And I have the default javascript included:
<%= javascript_include_tag :defaults %>
And the source head resolves as:
<script src="/javascripts/jquery.js?1302296105" type="text/javascript"></script>
<script src="/javascripts/rails.js?1302139751" type="text/javascript"></script>
<script src="/javascripts/application.js?1305999509" type="text/javascript"></script>
And in the controller I have:
respond_to :html, :json
However when I click the link it loads as regular link, not ajax and on the server log:
Processing by BooksController#index as HTML
What am I missing?
Make sure that you have installed the jQuery UJS Plugin:
Add this to your gemfile:
gem 'jquery-rails', '>= 1.0.3'
And then run:
bundle install
rails g jquery:install
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With