# Generate rails models from an existing database

**URL:** <https://www.ruby-forum.com/t/generate-rails-models-from-an-existing-database/147442>\
**Category:** Rails\
**Created:** [September 1, 2008, 9:41pm UTC](https://www.ruby-forum.com/t/generate-rails-models-from-an-existing-database/147442 "2008-09-01T21:41:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 1, 2008, 9:41pm UTC](https://www.ruby-forum.com/t/generate-rails-models-from-an-existing-database/147442/1 "2008-09-01T21:41:08Z")

</div>

Hi,

I have used a tool to create a rails conform database, meaning that  
all the tables and columns follow the rails conventions. The foreign  
keys and relationship tables/columns also exist.

Now I would like to generate all the models from this existing  
database at once. It would be great to automatically create the  
controllers and views, too - to have simple but functional CRUD  
application.

How do I do that - at once?

Fritz

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 2, 2008, 4:00pm UTC](https://www.ruby-forum.com/t/generate-rails-models-from-an-existing-database/147442/2 "2008-09-02T16:00:46Z")

</div>

On Sep 1, 2008, at 3:37 PM, removed\_email\_address@domain.invalid wrote:

> How do I do that - at once?
> 
> Fritz

You could search for “magic models” by Dr. Nic. I don’t know if it  
generates the models or just lets you have “empty” model classes and  
figures out the associations on-the-fly.

-Rob

Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid
