Forum: Ruby on Rails Ideas for rails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
rogerdpack (Guest)
on 2007-02-16 04:42
(Received via mailing list)
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.
Mohit S. (Guest)
on 2007-02-16 05:12
(Received via mailing list)
rogerdpack wrote:
>
Would this help?
http://magicmodels.rubyforge.org/

Cheers
Mohit.
Philip H. (Guest)
on 2007-02-16 05:30
(Received via mailing list)
> 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

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...
rogerdpack (Guest)
on 2007-02-16 05:34
(Received via mailing list)
Yeah something similar to that--it would be nice to also 'see' the
schema, for easy reference.
rogerdpack (Guest)
on 2007-02-16 05:34
(Received via mailing list)
thanks!
This topic is locked and can not be replied to.