# How RoR works with table created on fly

**URL:** <https://www.ruby-forum.com/t/how-ror-works-with-table-created-on-fly/117060>\
**Category:** Rails\
**Created:** [October 12, 2007, 4:21pm UTC](https://www.ruby-forum.com/t/how-ror-works-with-table-created-on-fly/117060 "2007-10-12T16:21:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f9ae1b/32.png) [@nick](https://www.ruby-forum.com/u/nick)\
**Post date:** [October 12, 2007, 4:21pm UTC](https://www.ruby-forum.com/t/how-ror-works-with-table-created-on-fly/117060/1 "2007-10-12T16:21:54Z")

</div>

Hi, all  
I’ve trying to look for answers for my problem but so far couldn’t  
find one, hopefully someone can tell me what to do. In my application,  
I  
have to let user can create new table, and they can add or  
delete columns. The tables they created, I can’t do things that RoR  
usually  
can do, like ( Table.find\_by\_id ), because they are not modeled. Is  
there any  
way that I can setup model for a table that user created on fly?  
Thanks for your help!

The code I used to create table is like this:  
ActiveRecord::Base.connection.create\_table :table\_name do |t|  
t.column :name, :string  
end

---

<div class="post-metadata">

**Author:** ![nick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f9ae1b/32.png) [@nick](https://www.ruby-forum.com/u/nick)\
**Post date:** [October 12, 2007, 4:46pm UTC](https://www.ruby-forum.com/t/how-ror-works-with-table-created-on-fly/117060/2 "2007-10-12T16:46:05Z")

</div>

You might find Dr Nic’s magic models to be of interest: http://  
[magicmodels.rubyforge.org/dr\_nic\_magic\_models/](http://magicmodels.rubyforge.org/dr_nic_magic_models/)

Fred

---

<div class="post-metadata">

**Author:** ![nick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f9ae1b/32.png) [@nick](https://www.ruby-forum.com/u/nick)\
**Post date:** [October 12, 2007, 7:31pm UTC](https://www.ruby-forum.com/t/how-ror-works-with-table-created-on-fly/117060/3 "2007-10-12T19:31:58Z")

</div>

Nic’s magic is amazing.  
Thank you so much, Fred!

On Oct 12, 10:44 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
