Skip to main content


Showing posts from January, 2010

Rails: The REST Religion

I like Rails. I like Web services. I even like making a strong distinction between GET and POST for all the standard reasons. However, I do not like the REST religion. It's a simple fact of life that Web browsers don't currently support DELETE and PUT. Rails compensates for this by passing a parameter _method=DELETE. The REST religion contends that REST is simple because it cooperates with how the Web is supposed to work. However, the Web as most people use it is browser-based, and my current browser doesn't support DELETE and PUT. In fact, I'm going to have to deal with browsers that don't support DELETE and PUT for many years to come. Hence, Rails' use of _method=DELETE is a HACK in order to try to force the Web to be something it isn't, all the while claiming that RESTful routing is the way the Web is meant to work. Nowhere is this more evident than in this code: <%= link_to "Delete", project_path(@project), :method => :delete %&

Ruby: Strings

Doh! I forgot Ruby has mutable strings. I expected "s << something" to be the same as Python's "s += something". However, in Ruby "<<" actually modifies the string. That's really bad if there are any objects that have a pointer to the same string and aren't expecting it to be modified. (I'm not criticizing Ruby. I just wasn't expecting it. I would never make that same mistake with something I knew was modifiable, like a hash.)