Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 如何正确实现jsonb阵列的where?_Ruby On Rails_Activerecord_Ruby On Rails 5_Ruby On Rails 6 - Fatal编程技术网

Ruby on rails 如何正确实现jsonb阵列的where?

Ruby on rails 如何正确实现jsonb阵列的where?,ruby-on-rails,activerecord,ruby-on-rails-5,ruby-on-rails-6,Ruby On Rails,Activerecord,Ruby On Rails 5,Ruby On Rails 6,我添加了要在其中存储ID的jsonb字段 接下来,我需要根据该字段的内容对记录进行“搜索” 在任何地方,包括文档(),我都看到了这个操作符-@>。但我没有成功地使用它: User.where.not(“迁移\u id@>?”,1) 请告诉我,怎么做才对?这应该行得通 User.where.not(“迁移”\u id@>?,“1”) ActiveRecord::StatementInvalid (PG::UndefinedFunction: ERROR: operator does not e

我添加了要在其中存储ID的jsonb字段

接下来,我需要根据该字段的内容对记录进行“搜索”

在任何地方,包括文档(),我都看到了这个操作符-
@>
。但我没有成功地使用它:

User.where.not(“迁移\u id@>?”,1)
请告诉我,怎么做才对?

这应该行得通
User.where.not(“迁移”\u id@>?,“1”)

ActiveRecord::StatementInvalid (PG::UndefinedFunction: ERROR:  operator does not exist: jsonb @> integer)
LINE 1: ...s".* FROM "users" WHERE NOT (migration_ids @> 1) LIMI...
                                                      ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.