When showing a project, the user can add a decision via a form_for and its partial. Is there some way of avoiding reloading the page and just creating the record silently? In the controller method (adddecision) I have:
respond_to do |format|
if @decision.save
format.html { redirect_to(@project) }
format.xml { head :ok }
else
format.html { render :action => "show" }
format.xml { render :xml => decision.errors, :status => :unprocessable_entity }
end
I’ve tried redirect_to(:back) etc – still getting a page reload.
Use
remote_form_forto submit the form in the background via Ajax.You can handle the error case (and the success case, if you like) in JavaScript. See the docs.