What columns does an ActiveRecord model have?
Something that bugs me about using ActiveRecord models is that I have to look in schema.rb file to remember what columns a model has.
This is a little plugin I bunged together on the (long) train journey home from Scotland on Rails.
What it does is put a comment block in all of your ActiveRecord models detailing what columns this model has. The beauty is that it changes every time you run
rake db:migrate in development mode – so once it’s installed it will always be up to date. Your models will now look like this:
class User < ActiveRecord::Base
# === List of columns ===
# id : integer
# name : string
# created_at : datetime
# updated_at : datetime
Source code here:
Install it like this:
script/plugin install git://github.com/thechrisoshow/what_column.git
After you’ve installed it run this rake task to create the initial comment blocks.
Every time you run
rake db:migrate from then on the comment blocks will be updated.
If you get sick of What Column, and you want to uninstall it do this:
Delete the plugin from the
This file writes stuff into your model files, and it may destroy stuff. So make sure you use a source control system – you know, just in case.