Today I found that code


headers['status'] = '500'

doesn’t do what I want with Mongrel: HTTP Status header is still 200 while with Webrick it’s happily set to 500.I tried it with Rails 1.2.5 and 2.0 and Mongrel 1.1.1 both on Windows and Linux.Luckily using this instead helps (though I liked the previous code more):


render :action => action_name, :status => '500'

Why I wanted to set the goddamn header in first place? Because it seem to be a clean way to tell Ajax helper not to hide a form after failed submit:


<%remote_form_for :receipt, :url => { :action => "add_receipt"}, :success => "$('add_receipt_form').hide();",
    :html => {:id => "add_receipt_form", :style => "display: none;"} do |form| %>

This :success, it relies on HTTP Status header.



One Response to “Communicating HTTP status and Mongrel”  


  1. 1 Rails 2.0 and Globalize « Artem Vasiliev’s Weblog

Leave a Reply