REST in Place plugin

Plugin details

"REST in Place" is an AJAX Inplace-Editor that talks to RESTful controllers. It requires absolutely no additional server-side code if your controller fulfills the following REST preconditions:

- It uses the HTTP PUT method to update a record
- It delivers an object in XML form for requests with "Accept: application/xml" headers

The editor works by PUTting the updated value to the server and GETting the updated record afterwards to display the updated value. That way any authentication methods or otherwise funky workflows in your controllers are used for the inplace-editors requests.

Websitehttp://jan.varwig.org/archiv/rest-in-place Repositoryhttp://svn.varwig.org/rails/plugins/rest_in_place/ Author Jan Varwig Tags editor LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install http://svn.varwig.org/rails/plugins/rest_in_place/

REST in Place needs the jQuery library to work.

To make a piece of Text inplace-editable, wrap it into an element (a span usually) with class "rest_in_place". The editor needs 3 pieces of information to work: a URL, an object name and the attribute name. These are provided as follows:

put attributes into the element, like this:

span class="rest_in_place" url="/users/1" object="user" attribute="name"
  Johnny
/span



if any of these attributes is missing, DOM parents of the elemet are searched for them. That means you can write something like:

div object="user" url="/users/1"
  Name:  span class="rest_in_place" attribute="name" >Johnny/span
  eMail: span class="rest_in_place" attribute="email">johnny@somehost.com/span
/div



You can completely omit the url, the current documents url is taken then. With proper RESTful controllers this should always work, the url-attribute is for cases when you want to edit a resource that is displayed as part of a non-RESTful webpage.

Rails provides the dom_id helper that constructs a dom id out of an ActiveRecord for you. So, your HTML page may look like this:

div> id="user_1"
  Name:  span> class="rest_in_place" attribute="name" >Johnny /span>
  eMail: span> class="rest_in_place" attribute="email">johnny@somehost.com /span>
/div>



REST in Place recognizes dom_ids of this form and derives the object parameter from them, so that (with the current documents url used) you really only need to provide the attributes name in most cases.

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: Guest, 4 months ago