views:

266

answers:

2

In some Rails model definitions, there is a comment block at the top that contains the schema information.

# == Schema Information                                   
# Schema version: 20090122060318                          
#                                                         
# Table name: table_name
#                                                         
#  id            :integer(4)      not null, primary key   
...

When does this get updated? Is it only generated once, when you use the generator script to create the model? Is there a way to update this block when migrations are performed?

+5  A: 

Seems like output of the annotate_models plugin. Just install it and run annotate in your rails root and the schema information will update automatically. Ideally, run it after each migration.

Milan Novota
+2  A: 

You could also use the annotate-models gem. It's a bit less intrusive as there's no plugin needed.

Usage:

% sudo gem install annotate-models
% annotate
Annotated Product, User, Role

You can find more about it on the gem's homepage.

reto