ITeye博客

financing应用的model

hongan · 2009-07-14 15:14 · Ruby · Markdown

user:
- name: string
- password: string
- has_many: [item,record]

item:
- content: string
- types: integer
- belongs_to: [user,item]
- has_many: [item,record]


record:
- content: text
- money: number
- date: date
- belongs_to: [item,user]

 

Ruby model:

class CreateUsers < ActiveRecord::Migration
  def self.up
    create_table :users do |t|
      t.string :name
      t.string :password

      t.timestamps
    end
  end

  def self.down
    drop_table :users
  end
end

 

class CreateItems < ActiveRecord::Migration
  def self.up
    create_table :items do |t|
      t.string :content
      t.integer :types
      t.references :user
      t.references :item

      t.timestamps
    end
  end

  def self.down
    drop_table :items
  end
end

 

class CreateRecords < ActiveRecord::Migration
  def self.up
    create_table :records do |t|
      t.text :content
      t.decimal :money
      t.date :date
      t.references :item
      t.references :user

      t.timestamps
    end
  end

  def self.down
    drop_table :records
  end
end

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。