# Programmatically generate models/scaffolds?

**URL:** <https://www.ruby-forum.com/t/programmatically-generate-models-scaffolds/104030>\
**Category:** Rails\
**Created:** [May 13, 2007, 5:48am UTC](https://www.ruby-forum.com/t/programmatically-generate-models-scaffolds/104030 "2007-05-13T05:48:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lefnire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/90ced4/32.png) [@lefnire](https://www.ruby-forum.com/u/lefnire)\
**Post date:** [May 13, 2007, 5:48am UTC](https://www.ruby-forum.com/t/programmatically-generate-models-scaffolds/104030/1 "2007-05-13T05:48:15Z")

</div>

first, let me explain what I’m trying to do because I might be going  
about this all wrong.

I want the user to be able to CRUD (create, read, update, destroy) table  
definitions as well as their rows. So the user should be able to delete  
existing tables, add a table with user-defined columns, change the  
columns of an existing table, etc. After that, the user should be able  
to CRUD rows for those tables.

If you’re wondering why I was to be able to do this, here’s my scenario  
(skip this paragraph if you don’t care). The web page is a 2-column  
layout with a tree-view on the left. the treeview lists each schema  
(table) and their respective instances (rows). so in the treeview is  
listed things like ‘volunteers’, ‘donors’, ‘events’, etc. I want the  
user to be able to modify a volunteer definition (modify table columns)  
as well as add volunteers to the list. Also, I want the user to be able  
to add a new user-defined schema (table). When a schema node is  
clicked, the content-pane is populated with the the modifiable schema  
definition. When an instance is clicked, the page is populated with the  
modifiable row information.

Ok, that’s some obvious day-to-day rails programming, so I’m sure i’m  
missing something essential. My question is if I can programmatically  
generate models/scaffolds per newly created tables (if so how), and if  
not how I should go about this.

---

<div class="post-metadata">

**Author:** ![lefnire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/90ced4/32.png) [@lefnire](https://www.ruby-forum.com/u/lefnire)\
**Post date:** [May 13, 2007, 7:58am UTC](https://www.ruby-forum.com/t/programmatically-generate-models-scaffolds/104030/2 "2007-05-13T07:58:55Z")

</div>

I have the same question. I think maybe we need to use a cgi to run  
scaffold script…

On 5ÔÂ13ÈÕ, ÉÏÎç11Ê±48·Ö, Tyler R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![lefnire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/90ced4/32.png) [@lefnire](https://www.ruby-forum.com/u/lefnire)\
**Post date:** [May 13, 2007, 10:02am UTC](https://www.ruby-forum.com/t/programmatically-generate-models-scaffolds/104030/3 "2007-05-13T10:02:01Z")

</div>

[http://rubyurl.com/0AG](http://rubyurl.com/0AG)

b

---

<div class="post-metadata">

**Author:** ![lefnire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/90ced4/32.png) [@lefnire](https://www.ruby-forum.com/u/lefnire)\
**Post date:** [May 22, 2007, 5:23pm UTC](https://www.ruby-forum.com/t/programmatically-generate-models-scaffolds/104030/4 "2007-05-22T17:23:16Z")

</div>

not yet ☹

p3rlhax wrote:

> Hi Tyler
> 
> Did you figure out how to do this ? I have the exact same requirement.
> 
> Thanks  
> p3rlhax  
> Tyler R. wrote:

---

<div class="post-metadata">

**Author:** ![lefnire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/90ced4/32.png) [@lefnire](https://www.ruby-forum.com/u/lefnire)\
**Post date:** [May 22, 2007, 11:26am UTC](https://www.ruby-forum.com/t/programmatically-generate-models-scaffolds/104030/5 "2007-05-22T11:26:22Z")

</div>

Hi Tyler

Did you figure out how to do this ? I have the exact same requirement.

Thanks  
p3rlhax  
Tyler R. wrote:

> first, let me explain what I’m trying to do because I might be going  
> about this all wrong.
> 
> I want the user to be able to CRUD (create, read, update, destroy) table  
> definitions as well as their rows. So the user should be able to delete  
> existing tables, add a table with user-defined columns, change the  
> columns of an existing table, etc. After that, the user should be able  
> to CRUD rows for those tables.
> 
> If you’re wondering why I was to be able to do this, here’s my scenario  
> (skip this paragraph if you don’t care). The web page is a 2-column  
> layout with a tree-view on the left. the treeview lists each schema  
> (table) and their respective instances (rows). so in the treeview is  
> listed things like ‘volunteers’, ‘donors’, ‘events’, etc. I want the  
> user to be able to modify a volunteer definition (modify table columns)  
> as well as add volunteers to the list. Also, I want the user to be able  
> to add a new user-defined schema (table). When a schema node is  
> clicked, the content-pane is populated with the the modifiable schema  
> definition. When an instance is clicked, the page is populated with the  
> modifiable row information.
> 
> Ok, that’s some obvious day-to-day rails programming, so I’m sure i’m  
> missing something essential. My question is if I can programmatically  
> generate models/scaffolds per newly created tables (if so how), and if  
> not how I should go about this.
