views:

218

answers:

4

I seem to recall that there was a plugin or Rake snippet that would put comments in various Model classes after running a migration? It's a chore to have to look at db/migrate/X when I want to see which fields a given model has.

If not, I'll write one, of course. :)

+2  A: 

You may be thinking of the Annotate Models plugin at: http://repo.pragprog.com/svn/Public/plugins/annotate_models/

I believe that does exactly what you describe, although I haven't personally used it in a while, so can't vouch for its behaviour on more recent Rails versions.

Regards, NeilS.

I used this plugin for a while but stopped also.It doesn't really solve the problem (since you often have to check to see if the annotations are still accurate, which defeats the purpose of using them), and it adds a bunch of noise to your checkin that presumably has nothing to do with most of the files that you changed by re-annotating.Just look at db/schema.rb, or if you want to solve this via overkill, figure out a way to make these annotations get dropped at checkin time *and* auto update during db:migrate. :)
Jamie Flournoy
I'll grab the source and write an update so that it updates on db:migrate; dropping at checkin isn't really an issue for me, though.
Don Werve
+3  A: 

There is a school of thought that suggests you you shouldn't put attribute comments in the model as it breaks the principal of DRY. I won't argue the point. However, one real nice way of identifying attributes of the model is to simply type the Model name when you are in ./script/console

 > User
=> User(id: integer, loginname: string, password: string, fullname: string, created_at: datetime, updated_at: datetime)

I always have ./script/console session open when developing Rails.

BigCanOfTuna
A: 

A drier approach would be:

script/console

You save two characters :)

Riccardo
A: 

Here is what I do for the sake of my fingers

I created useful rails aliases in my .bash_profile file

alias sc="script/console"
alias sr="script/runner"
alias sa="script/about"
alias ss="script/server thin"

So whenever I need to see my user.rb schema model for example, I just type this short command on my Terminal

sr 'p User'
Arie Keren