# In place editing for non-standard values

**URL:** <https://www.ruby-forum.com/t/in-place-editing-for-non-standard-values/143217>\
**Category:** Rails\
**Created:** [July 16, 2008, 2:39pm UTC](https://www.ruby-forum.com/t/in-place-editing-for-non-standard-values/143217 "2008-07-16T14:39:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mojca](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8e7dd6/32.png) [@mojca](https://www.ruby-forum.com/u/mojca)\
**Post date:** [July 16, 2008, 2:39pm UTC](https://www.ruby-forum.com/t/in-place-editing-for-non-standard-values/143217/1 "2008-07-16T14:39:21Z")

</div>

I would like to add in-place editing functionality to my application,  
but I fetch & store the data from/into a weird source that requires some  
transformations to be done before displaying & storing the content.

A slightly (over)simplified example could be the following.

Assume that I have a table “data” with two columns:

id name

* * *

1 XX  
2 XXXX  
3 XXX

show.html.erb would return the following for each object:

## data/1

## this is id: 1 length: 2 [edit button]

## data/2

## this is id: 2 length: 4 [edit button]

## data/3

## this is id: 3 length: 3 [edit button]

I would like to press [edit button] (or a simple link) that should  
change the number into editable field that should only accept numbers.

* * *

## this is id: 2 length: |_4_| [save button]

And when changing 4 into 6 and pressing [save button] I want to modify  
the name in database to store six X characters instead of four:

id name

* * *

1 XX  
2 XXXXXX  
3 XXX

and return to normal show page:

## data/2

## this is id: 2 length: 6 [edit button]

Is there a simple way to do that with existing macros? (I’m using rails  
2.1.)

Thanks a lot,  
Mojca
