The only problem with that is that a developer may create a migration
and forget to update the field descriptions in the model. Out of date
and wrong comments are the worst.
I like the idea of patching migrations to use the field comment in the
database. Then plugins like annotate models could pull the comment and
write it to the model file for easy access.
-- James Healy <ji...@deefa.com> Wed, 04 Nov 2009 12:11:46 +1100
The only problem with that is that a developer may create a migrationand forget to update the field descriptions in the model. Out of date
and wrong comments are the worst.
I like the idea of patching migrations to use the field comment in the
database. Then plugins like annotate models could pull the comment and
write it to the model file for easy access.
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?
Yeah, loved it (taking noted mild annoyances into account). There's
been some small modifications by me and others too to make it a bit
more usable:
http://github.com/lightningdb/annotate_models
Cheers,
Dave
I used to use a customised version of "rake model_annotations:update",
which allowed you to place a comment next to each field that wouldn't
get blown away if you re-ran the task. I then had a "rake
model_annotations:missing" task which listed all models/fields with
missing annotations. Useful in team environments, and if you can't
express enough information in the name of the actual fields.
Cheers,
Nathan
I use it and find it handy for keeping a list of DB fields within easy
reach when working on a model. I don't think it currently extracts
fields comments from the DB however.
One minor irritation is that it doesn't interact nicely with files that
have a ruby 1.9 encoding statement (# coding: utf-8 and friends) at the
top of the file.
-- James Healy <ji...@deefa.com> Wed, 04 Nov 2009 12:37:36 +1100
I use it and find it handy for keeping a list of DB fields within easy
Josh Price wrote:
> Does anyone still use the annotate models plugin?
>
> http://agilewebdevelopment.com/plugins/annotate_models
>
> It takes your schema and put it as a comment block at the top of your model
> classes. Combined with migration-based comments this might work for you.
>
> When I used this a while back I found keeping it up to date manually mildly
> annoying, but if your schema isn't going to change much then it might be a
> good solution.
reach when working on a model. I don't think it currently extracts
fields comments from the DB however.
Does anyone still use the annotate models plugin?
Yeah, loved it (taking noted mild annoyances into account). There's
been some small modifications by me and others too to make it a bit
more usable:
http://github.com/lightningdb/annotate_models
I have my SQL gui application open all the time where I can look at
everything as well as query the db. I never looked at schema.rb
Cheers,
Anthony
> I store the database schema in my mind and know what every column's
> purpose is.
So you've never working on anything bigger than a blogging engine then?
Cheers,
Gareth Townsend
http://www.garethtownsend.info
http://www.melbournecocoaheads.com
From: http://www.google.com.au/search?q=define%3A+joke
Definitions of joke on the Web:
wouldn't it be good to document them using some Model specs so that it
makes clear what the field does, and how it affects the payment
system?
Of course annotate_model will always be there, I think it even
annotate your specs btw...
ceo