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.

Enter…What Column!

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 
# =======================
end  

Source code here:

http://github.com/thechrisoshow/what_column/

Installation

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.

rake what_column:add

Every time you run rake db:migrate from then on the comment blocks will be updated.

Uninstallation

If you get sick of What Column, and you want to uninstall it do this:

rake what:column:remove

Delete the plugin from the vendor/plugins/what_column directory

Warning

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.

Need to find a lawyer for your business? Get in touch with my company Lexoo and we'll find you a great one for free.