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

查看:31
本文介绍了如何在 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天全站免登陆