How to make Rails 4.2 work with Postgres Jsonb?

后端 未结 1 1914
醉话见心
醉话见心 2020-12-19 07:07

I\'ve seen a few blog posts claiming that rails 4.2 added support for the new Jsonb data type in Postgres 4.2.

However, googling gets me zero results on how to act

相关标签:
1条回答
  • 2020-12-19 07:22

    It's part of the not yet released version of Rails 4.2 (currently 4.2.0.rc3). To use the datatype, specify the jsonb type when creating a table:

    create_table :users do |t|
      t.jsonb :extra_info
    end
    

    or add to an existing table

    add_column :users, :extra_info, :jsonb
    

    Since jsonb is virtually the same as json except for the internal storage, the way you work with the column is the same as well.

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