如何在rails中解析和显示hstore键/值
我有一个postgres hstore存储json字符串的数据类型。
我希望能够在rails html页面上解析并显示键/值。
不知何故,我只是不知道如何在数据字段上运行解析并显示字符串中列出的每个键/值。
<-- this is the hstore json string <-- this is an error, just to show
例如,payment_account.data包含{“hello”=>“world”,“great”=>“job”}
这是index.html.erb代码。 https://gist.github.com/axilaris/9174206
我该怎么做才能做到这一点? 解析hstore字符串以在rails中显示查询结果?
您可以像数组一样访问数据:
<%= payment_account.data['hello'] %>
这将显示world