浏览 2092 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2008-06-24
Objective: To add a new column in pre-built product
1. create a migration task: add a column for product ruby script/generate migration add_price 2. edit db/migrate/*****_add_price.rb class AddPrice < ActiveRecord::Migration def self.up add_column :products, :price, :decimal, :precision => 8, :scale => 2, :default => 0 end def self.down remove_column :products, :price end end 3. migrate the new product into database rake db:migrate #Please confirm coressponding table in database. 4. rebuild scaffold product ruby script/destroy scaffold product ruby script/generate scaffold product title:string price:float description:text image_url:string #the scaffold product should be automatically rebuilt, but actually it did not on my machine. If someone can help me out, appreciate. 5. start Webrick server. ruby script/server 6. test depot in web browser. http://localhost:3000/products 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |