# Ideas for rails

**URL:** <https://www.ruby-forum.com/t/ideas-for-rails/85763>\
**Category:** Rails\
**Created:** [February 16, 2007, 3:42am UTC](https://www.ruby-forum.com/t/ideas-for-rails/85763 "2007-02-16T03:42:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [February 16, 2007, 3:42am UTC](https://www.ruby-forum.com/t/ideas-for-rails/85763/1 "2007-02-16T03:42:43Z")

</div>

Here are a few suggestions, wondering what others thought:  
When you generate a model for a DB table, it would be nice if the  
model.rb contained the DB schema (kind of like # commented out schema)  
right in the model file. This would make reference WAY easier and put  
all of the DB stuff in one easy file. Thanks.

also nice, of course, woudl be for rails to try and ‘guess’ the  
relationships among tables, and auto-generate the ‘has\_many’ or  
‘belongs\_to’, if it is possible based on the syntax. Thanks.

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [February 16, 2007, 4:12am UTC](https://www.ruby-forum.com/t/ideas-for-rails/85763/2 "2007-02-16T04:12:45Z")

</div>

rogerdpack wrote:

> 

Would this help?  
[http://magicmodels.rubyforge.org/](http://magicmodels.rubyforge.org/)

Cheers  
Mohit.

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [February 16, 2007, 4:34am UTC](https://www.ruby-forum.com/t/ideas-for-rails/85763/3 "2007-02-16T04:34:46Z")

</div>

Yeah something similar to that–it would be nice to also ‘see’ the  
schema, for easy reference.

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [February 16, 2007, 4:30am UTC](https://www.ruby-forum.com/t/ideas-for-rails/85763/4 "2007-02-16T04:30:45Z")

</div>

> Here are a few suggestions, wondering what others thought:  
> When you generate a model for a DB table, it would be nice if the  
> model.rb contained the DB schema (kind of like # commented out schema)  
> right in the model file. This would make reference WAY easier and put  
> all of the DB stuff in one easy file. Thanks.

[http://plugins.radrails.org/directory/show/12](http://plugins.radrails.org/directory/show/12)

From the readme…

Add a comment summarizing the current schema to the top  
of each ActiveRecord model source file:

# Schema as of Sun Feb 26 21:58:32 CST 2006 (schema version 7)

# 

# id :integer(11) not null

# quantity :integer(11)

# product\_id :integer(11)

# unit\_price :float

# order\_id :integer(11)

# 

class LineItem \< ActiveRecord::Base  
belongs\_to :product

```
 . . .

```

Does not cope with models in sub-directories of app/models.

Author:  
Dave T.  
Pragmatic Programmers, LLC

Released under the same license as Ruby. No Support. No Warranty.

Back up your model files before using…

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [February 16, 2007, 4:34am UTC](https://www.ruby-forum.com/t/ideas-for-rails/85763/5 "2007-02-16T04:34:46Z")

</div>

thanks!
