# Virtual/dynamic tables?

**URL:** <https://www.ruby-forum.com/t/virtual-dynamic-tables/185647>\
**Category:** Rails\
**Created:** [March 24, 2010, 2:57am UTC](https://www.ruby-forum.com/t/virtual-dynamic-tables/185647 "2010-03-24T02:57:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mike](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@mike](https://www.ruby-forum.com/u/mike)\
**Post date:** [March 24, 2010, 2:57am UTC](https://www.ruby-forum.com/t/virtual-dynamic-tables/185647/1 "2010-03-24T02:57:58Z")

</div>

Hi,

I’m trying to figure out a way for my users to create their own forms  
and store the data collected into their own customized table.

For an example (though unlikely), say they want to create their own  
variant of an address book. They specify the fields, some field  
requirements (unique, size limit), perhaps a regex expression  
(possibly from a list of examples) to validate the data, then I create  
the forms for creation/update and the views for browsing, searching,  
deleting.

Is there a plugin or example out there that can help with something  
like this?

For dynamic creation of the storage, I was thinking of an architecture  
like so:

1. VirtualTable:
  - name:string
  - user\_id:integer

2. DataColumn:  
\* virtual\_table\_id:integer  
\* name:string  
\* data\_type:string  
\* limit:integer  
\* regex\_validator:string  
\* unique:boolean
3. DataRow  
\* virtual\_table\_id:integer  
\* created\_at:datetime  
\* updated\_at:datetime
4. DataString  
\* data\_column\_id:integer  
\* data\_row\_id:integer  
\* data\_value:string
5. DataText  
\* data\_column\_id:integer  
\* data\_row\_id:integer  
\* data\_value:text

I’m guessing I’d have to put most of the CRUD logic in a single model,  
perhaps called VirtualData. Hopefully, the controller can just do  
something like VirtualData.create params, and the magic happens inside  
the model.

I haven’t worked out the details there yet.

Is there a better way?
