如何在Rails中使用jsonb [英] how to use jsonb in rails

查看:206
本文介绍了如何在Rails中使用jsonb的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用Postgresql 9.4作为后端的Rails项目。我有这样的列:

I have a rails project with Postgresql 9.4 as backend. I have column like this:

t.json :slot_details, null: false, default: {}

如何将其从JSON更改为JSONB?我应该添加索引并将其更改为JSONB吗?

How do I change this to JSONB from JSON? Should I add index and that will be changed to JSONB?

推荐答案

这是它与Rails 4.2一起工作的方式

Here is it how it worked with Rails 4.2

t.jsonb :slot_details, index: true, default: {}

以上答案为我带来了错误。

The answer above threw errors for me.

这篇关于如何在Rails中使用jsonb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆