in-place editing in Rails 2.0

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.

Advertisements

One thought on “in-place editing in Rails 2.0

  1. You have seemed to hit the best and worst of the opensource community in your blog.

    The Best
    The opensource approach has fueled rapid collaborative coding of patches and project extensions.

    The Worst
    Lack of documentation. Although we have gotten better over the years, there is still a lack of development on many projects. I find myself “wasting” time finding Rails documentation that I thought would be easy to find.

    We have started to try to help this effort. Check it out if you get a chance.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s