I do asynchronous request via remote_form_for,I expect it will update
partial content within current page, but it end up redirect to a new
page,I guess may be cause controller consider ' format.html' was I
need.so I want to try other reponse format.The problem is I don know
how to specify the response format in post action.
whether the approach is set 'accpt' in request Header? If it is,How?
Not sure I fully understand your question, but the remote_form_for
method is a post via AJAX and so you need to setup your controller to
expect a ajax request.
Here is what I do:
respond_to do |format|
Then create an rjs template named the same as your action in the
controller that updates the part of the page you want updated.
So if your action is called Create, you would create a rjs template
called create.rjs and in that template you would have
page.replace_html :name_of_element, :partial => 'new_content'
which will replace the id of the element you want to replace with the
Hope that helps.