Correctly Handle OpenID Updates

OpenID is pretty well established as a login infrastructure, but a topic often ignored is correctly letting the user change his saved OpenID. Don’t just save the text they enter! Verify that they’ve entered their valid OpenID. The user model needs to pass this test: The view on /account/edit needs to pass this test: And, […]

My Rails Development Environment, version 2: Scribes, Nautilus, and gnome-terminal

On a whim I tried Scribes for a day. It’s not terrible: autosaving, keyword completion, templates, syntax highlighting, and a sleek look. There’s a lot I miss from vim, but after two weeks of Scribes I’m mostly adjusted. (I really, really, really look forward to the autosave misfiring fix.) At first I thought I couldn’t […]

My Rails Development Environment, version 1: vim and screen

Lately I’ve changed the way I manage the code on my Rails projects; this is the overview on how I did it for the past two years. I’ve used vim since my first programming job eight years ago. I’ve use it for email, papers, programming, notes—anything. I instinctively hit escape when I finish typing; my […]

STI and Multiple Databases in Rails

I admit, I believed it when DHH said that Rails apps should communicate via REST if they want access to a shared database. I bought into the hype and even wrote a plugin to make this easier. Well, it’s slow. I don’t have real numbers, of course, because I’m not the type of person to […]

Truncating HTML in Ruby

Update: You should read the comments, then check out the extended verion of truncate_html that uses Tidy. For the blogging Web site we wanted snippets of blog post for the front page and search results. This wasn’t a problem at all for our test blog posts, which we made by pasting lorem ipsum into a […]

Retrieving Random Elements from an ActiveRecord

This one is short but not something I immediately thought of. It doesn’t rely on an ActiveRecord abstraction, but I originally thought it would need to, so the title is to save future Web searchers. The idea is that you want to create a list of all the Users, but ordered randomly. It turns out […]

In-Place-Editing Blank Fields

Rails’s in_place_editor_field method is a nice wrapper around Scriptaculous’s inPlaceEditor, except for empty fields. These show up as nothings with, if you’re lucky, a box around it. If you can find the inside of the box and click in it, then you can enter text; otherwise, you’re screwed. It took me a bit to figure […]

STI, acts_as_tree, and xml_response_from

More Land Brokr/NCRE integration means more xml_response_fromhackery. This one involves the message center. NCRE messages are STI trees. That is: class Message < ActiveRecord::Base acts_as_tree :order => ‘created_at DESC’ end class PurchaseMessage < Message def summary “blah blah” end end class OpenHouseMessage < Message def summary “blah blah” end end So the code to send […]

STI and to_xml

As I mentioned in the explanation for my response_from plugin, I have two apps that communicate via a private XML REST API. This is trivial using my xml_response_from method (in my response_from plugin) and with Rail's to_xml; trivial, that is, unless you want to use single table inheritance. For example, let's say you have:  class […]


It's not a big secret: I'm writing blogging software. This, in a sense, sucks because it's already been written many, many times; while I coded I often (like, every 20 minutes) tried to think of how this could be abstracted into a plugin or five. Since this is a big task I might do it […]