2015-04-01 74 views
0

我有以下模式:红宝石续集访问JSON场

Column |   Type    |  Modifiers   
---------+-----------------------------+------------------------ 
id  | text      | not null 
data | json      | not null 
created | timestamp without time zone | not null default now() 

如果我打开了PSQL我可以运行查询。

select id, data->'amount' as amount from plans; 

但是红宝石sequel宝石遗址吧。

puts $db.run("select id, data->'amount' as amount from plans") 

怎么了?

回答

1

需要#literal方法。

$db.run("select id, data -> #{ $db.literal('amount') } as amount from plans")