Create an ActiveRecord database table with no :id column?

前端 未结 1 865
抹茶落季
抹茶落季 2020-12-05 17:09

Is it possible for me to create and use a database table that contains no :id column in ActiveRecord, Ruby on Rails.

I don\'t merel

相关标签:
1条回答
  • 2020-12-05 17:47

    yup, looks like this:

    create_table :my_table, id: false do |t|
      t.string :key_column
      t.string :value_column
    end
    

    just make sure to include the

    id: false
    

    part.

    0 讨论(0)
提交回复
热议问题