Announcing JIPE: RESTful In-Place Editors for Rails Jul 15, 2008

Hi, everyone! I thought I'd take some time in-between my Journey 2.5 feature tour posts to talk about one of the components I wrote for the Journey 2.0 release: JIPE, or Jester In-Place Editors.

Jester is an open-source JavaScript library that lets you access RESTful data model objects from your scripts. (Unpacking that a little further, REST is an emerging web application industry standard that specifies a very simple standard set of methods for retrieving and editing data.)

In more concrete terms: Ruby on Rails, since version 1.2 or so, makes it very easy to write RESTful data objects. Ruby on Rails also used to have a nice helper method called in_place_editor, which let you do a neat trick: basically, you could show some information on your web page about an object, and have the user be able to edit it right there on the same page.

As an example, let's say you're looking at a blog post, and the web page shows you the post's title, author, and date.  You want to edit the title of the post, because you misspelled a word.  With in_place_editor, you could just click on the title, and it would turn into a text field, which you could then edit, and your changes would be instantly applied!  Nifty, eh?

Unfortunately, RESTful resources break all this, and the Rails team decided that in_place_editor belonged in a plugin anyway (and they were probably right).  Writing a new version of in_place_editor that used REST would have been possible, but kind of a pain.

Enter Eric Mill's awesome Jester library.  Jester makes it really easy to do REST stuff from JavaScript, so I figured it would be a snap to port in_place_editor over to Jester.  And it was!  The result is JIPE, which not only replaces in_place_editor, but also gives you a nice AJAXy image-based toggle widget for boolean fields.

I won't go into the full details of how you use JIPE here - you can find that out in the README file.  But just to give you a flavor of it, here's a JIPE-based editing view for a hypothetical blog post:

Title: <%= jipe_editor_for @post, :title %><br/>
Author: <%= jipe_editor_for @post, :author %><br/>
<%= jipe_editor_for @post, :body, :rows => 5 %>

See?  Easy.

To install JIPE in your Rails app, do this:

script/plugin install

Thanks, folks!  If you have any questions, comments, suggestions, etc., comment on this post or email me!