Right now I look in the db/schema.rb to see the list of fields associated with a model and assume that is where most other people look for these fields, which is why I wanted to put the descriptions there. My thinking is that repeating this list of fields again in the code in app/models is unDRY because you've now got to maintain the same list of fields in both places.
When you say most developers don't regularly check the schema.rb, how do you know what a model's fields are without doing this? I agree that most developers, myself included, usually go to the app/model file first when coding. This is one of the few things I find annoying about ActiveRecord because I often have to have the db/schema.rb and app/models file open at the same time. If there is a good way to add these comments to the model I'd rather describe them there so that they also appear in the rdoc. An example would probably help the most. Thanks for your quick reply! On Nov 4, 12:05 pm, Bodaniel Jeanes <[email protected]> wrote: > Why do you find describing the fields in the model unDRY? If it were me, > that's exactly where I'd put them as this is where developers will interact > with those fields the most. > > Another idea might be to patch migrations to use the field comment feature > of some DBs like MySQL. However without actually checking that, it's not > really helpful as most developers won't regularly check the schema.rb or the > raw database to see those values. > > Ultimately if the purpose is for documentation, it should be somewhere that > developers will expect to find documentation: the README, the doc/ > directory, or in comments in the code (such as in the model that it is > relevant to). > > Bo > > On Wed, Nov 4, 2009 at 10:56 AM, MarkBennett <[email protected]>wrote: > > > > > > > > > I'm working on an application where the fields in our model have very > > specific meanings and affect payments made to our users. Because of > > this understanding the purpose and meaning of each field is important. > > > I've been looking for the best way to describe the model fields, and > > would ideally like to leave comments in the db/schema.rb, however this > > if rebuild after I run each migration. What is the best way to > > document fields and to share their purpose with the team? I can't > > find a comment or description field to use the migration code, and > > describing each field in the model file itself doesn't seem very DRY. > > > Thanks! > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby or Rails Oceania" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rails-oceania?hl=en -~----------~----~----~----~------~----~------~--~---
