Rails 3.1.2, формы почему-то отправляются по два раза вместо одного…
# _form.html.erb<br>
<%= form_for @message, :remote => true do |f| %><br>
<div><br>
<%= f.hidden_field :user_id %><br>
</div><br>
<%= f.error_messages %><br>
<div><br>
<%= f.text_area :content %><br>
</div><br>
<div><br>
<%= f.submit(@message.new_record? ? "Post" : "Update") %><br>
</div><br>
<% end %><br>
<br>
# messages_controller.rb<br>
...<br>
def update<br>
@message = Message.find(params[:id])<br>
if @message.update_attributes(params[:message])<br>
respond_to do |format|<br>
format.html { redirect_to @message, :notice => "Successfully updated message." }<br>
format.json { render :json => { :response => :ok, :id => @message.id }.to_json,<br>
:status => :ok }<br>
format.js { render :js => "alert('ok!');" }<br>
end<br>
else<br>
format.html { render edit_message_path }<br>
format.json { render :json => { :response => :error }.to_json,<br>
:status => :error }<br>
format.js { render :js => "alert('fail!');" }<br>
end<br>
end<br>
...<br>