In my Rails 3 app I have a simple form like:
<%= form_tag({:controller => "activity", :action => "record"}, :method => "post", :remote => true, :class => "myform") do %>
<%= hidden_field_tag 'name', 'Jack' %>
<% end %>
my controller: (activity_controller.rb)
def record
#...something
respond_to |format|
format.js # app/views/activity/record.js.erb
end
end
In record.js.erb:
alert("hello");
When I’m trying to submit the form with jquery, from firebug console with:
$('.myform').submit();
the form makes a post request normally, but controller does not render record.js.
Redirects to localhost/activity/record.
I suppose that something wrong goes with my form..
Can you identify the problem?
Make sure that you have included the
rails.jsand thecsrf_meta_taghelper in your layout. It is a very common mistake.