Friday, April 23, 2010

Using annotate_models plugin

download or install annotate_models plugin (http://github.com/ganeshprasad/annotate_models) into vendor/plugins folder.
Now whenever you run the command rake annotate_models it will update the models with the schema.
Schema is also defined in ActiveRecord models whenever rake db:migrate is done.


Add a comment summarizing the current schema to the top or bottom of each of your…
* ActiveRecord models
  * Fixture files
  * Tests and Specs
  * Object Daddy exemplars
  * Machinist blueprints
The schema comment looks like this:
# == Schema Info
   #
   # Table name: line_items
   #
   #  id                  :integer(11)    not null, primary key
   #  quantity            :integer(11)    not null
   #  product_id          :integer(11)    not null
   #  unit_price          :float
   #  order_id            :integer(11)
   #

    class LineItem < ActiveRecord::Base
      belongs_to :product
     . . .

No comments:

Post a Comment