During the holiday break this week I decided to fix up one of my old projects and get it working under Rails 2.0. Things went well until last night, when I tried adding Ajax-style in-place editing to one of the forms. It doesn’t quite work as advertised, and the relevant information is scattered over the web, so these notes bring everything together in one place. (After the event I found Yen-Ju Chen’s notes, but they’re hard to find when you don’t know what to Google.)

First, as of 2.0 the in-place editing helper methods have been removed out of Rails and into a new plugin called in_place_editing. Unfortunately it doesn’t work on a simple out-of-the-box app: if you try it you’ll see an InvalidAuthenticityToken error reported in the log whenever the browser attempts to set the form field to a new value.

It turns out that this is a known defect in the new plugin, and thankfully there’s a patch provided on the defect report. Apply the patch and in-place editing works!

After the episode was over, I was struck by the power of the open source community. At 9pm I was cursing the incomplete, haphazard and dispersed documentation for the tools I was using; and at 10pm I was marvelling at the worldwide group of volunteers who found the defect, published a fix, and provided all of the tools required to manage that whole process and allow me to upgrade my installation. I’m awestruck when I try to list the layer upon layer of software that made that little code change possible, and by the legions of volunteers whose efforts have driven the evolution of today’s tools. The future’s bright — the future’s open.

Leave a Reply