Tuesday, July 22, 2008

scaffolding tricks

I've been working with a couple of models that have essentially the same column names, but contain data of different types.
Item
Food
PersonalHygiene
I took advantage of the rspec generator to create the scaffolding, but still only use one table for both Food and PersonalHygiene.

script/generate rspec_scaffold item type:string name:string unit:string quantity:string
script/generate rspec_scaffold food name:string unit:string quantity:string
script/generate rspec_scaffold personal_hygiene name:string unit:string quantity:string


Once I did this, I went back and removed the migrations for Food and PersonalHygiene and changed those models to inherit from Item.

rake db:migrate
rake spec

No comments: