Don’t know why this is happening, but after submitting a form via JS (using JQuery), it’s not resetting.
_problem_form.erb
<%= form_for [@industry, @problem], "id" => "problem_form", :remote => true do |f| %>
//fields
<% end %>
create.js.erb
<% if @problem.errors.any? %>
$("#errors").html("<%= escape_javascript(render :partial => 'layouts/error_messages', :locals => {:object => @problem })%>");
<% else %>
$("#problem_form_area").html("<%= escape_javascript(render :partial=> 'problems/problem_form') %>");
$(".problem_area").html("<%= escape_javascript(render @problems) %>");
$("#problem_form")[0].reset();
<% end %>
The POST request is sent and I can see everything update normally. The form just doesn’t reset.
The really strange part is that normally after a a successful POST, all the assets are fetched. However, this time, the server just hangs at
Completed 200 OK in 132ms (Views: 88.0ms | ActiveRecord: 2.5ms)
and the logs don’t indicate any GETs to my CSS or JS files.
On a side note, if I click on the submit button again (after the first POST and without refreshing the page), I get this message:
Started PUT “/industries/1/problems/71” for 127.0.0.1 at 2012-03-06
18:49:51 -0500AbstractController::ActionNotFound (The action ‘update’ could not be
found for ProblemsController):Rendered
/Users/hansy/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/unknown_action.erb
within rescues/layout (0.6ms
So, not sure why my form is converting the method from POST to PUT.
Any suggestions?
The first submit creates a new problem record (which is done by a POST request).
The same @problem is being sent back to the view. So now the form will update that record (which is done by a PUT request)