R – Auto-comment model on migration in Rails

migrationrubyruby-on-rails

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. 🙂

Best Solution

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.