2017-12-06 5 views
0

私はこのようになりdetails JSON列を持ついくつかのUserレコードを持っている:私はid2あるすべてのレコードを照会するにはどうすればよいポストグラムでJSONを使用すると、ネストされた配列をどのようにクエリできますか?

User.create(details: {accounts: [{name: 'one', id: 1}, {name: 'two', id: 2}]) 
User.create(details: {accounts: [{name: 'three', id: 3}, {name: 'two', id: 2}]) 
User.create(details: {accounts: [{name: 'three', id: 3}, {name: 'four', id: 4}]) 

を?

+0

ここでチェックhttps://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query ORここのhttp://edgeguides.rubyonrailsを。 org/active_record_postgresql.html#json – LHH

答えて

関連する問題