`
hongan
  • 浏览: 176953 次
  • 性别: Icon_minigender_1
  • 来自: 佛山
社区版块
存档分类
最新评论

financing应用的model

    博客分类:
  • Ruby
阅读更多
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
 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics