2010-09-15

UI for Editing serialized ruby Hash stored in database

For one part of a new project of mine I have decided to store lots of data in a hash stored in a database column. Of course I employed this in my model, I needed a way for a user to edit this hash and save it back out to the database. I drew this up on the board today, and so far, in a very short amount of time, I finished how to output the serialized nested Hash.

Here's my logic that implements nested looping partials, only escaping the loop when the item is a string and not another hash. This provided for output of an infinitely nested hash.


And here's the output with a single record I just threw in there:(ignore the style, it's some inline css that took me 5 seconds to write)



Now I will be making this editable, (new key/value pairs, new hashes...) at whatever depth I see necessary for this order data.