rails的数据库字段类型,migrations中常用到

作者在 2022-10-16 10:50:32 发布以下内容

The ActiveRecord data types available in Rails 5.

  • :primary_key
  • :string
  • :text
  • :integer
  • :bigint
  • :float
  • :decimal
  • :numeric
  • :datetime
  • :time
  • :date
  • :binary
  • :boolean

These data types are used in instances such as migrations.

def change
  create_table :categories do |t|
    t.string :title
    t.boolean :is_subcategory
    t.string :permalink
    t.timestamps
  end
end

Ruby | 阅读 890 次
文章评论,共0条
游客请输入验证码
浏览2800149次
文章归档