I searched everything and cannot understand why this is not working.
I am trying to test a very simple ajax action. Here is my code:
Controller:
def commit respond_to do |format| format.html { redirect_to :action => "index" }
View:
<%= link_to "commit", :action => "commit", :remote => true %> <%= form_tag( :action => "commit", :remote => true, :method => :post) do %> <%= submit_tag "commit" %> <% end %> <div id='message'></div>
commit.js.erb
console.log('committed'); $('#message').html("committed");
The problem is that I will go to the commit method, but the page will reload, which will cause the remote => true point to fail. Also commit.js was never called.
Note 1: If I exclude this line, I get a blank / commit page. Turning it on, the page just reloads
Note 2: I tried both of these approaches suggested by other SO posts Note 3: I tried using link_to and form_tag links
Can anyone help? Thanks!
Jason source share