Ruby on rails 如何在rails中解析和显示hstore键/值

Ruby on rails 如何在rails中解析和显示hstore键/值,ruby-on-rails,ruby,json,postgresql,hstore,Ruby On Rails,Ruby,Json,Postgresql,Hstore,我得到了一个数据类型,即postgres hstore,它存储一个json字符串 我希望能够在rails html页面上解析和显示键/值 不知何故,我只是不知道如何在数据字段上运行解析并显示字符串中列出的每个键/值 <% @payment_accounts.each do |payment_account| %> <tr> <td><%= payment_account.name %></td> <td>

我得到了一个数据类型,即postgres hstore,它存储一个json字符串

我希望能够在rails html页面上解析和显示键/值

不知何故,我只是不知道如何在数据字段上运行解析并显示字符串中列出的每个键/值

<% @payment_accounts.each do |payment_account| %>
  <tr>

    <td><%= payment_account.name %></td>
    <td><%= payment_account.company %></td>
    <td><%= payment_account.data %></td>        <-- this is the hstore json string
     <td><%= Json.parse(payment_account.data) %></td>   <-- this is an error, just to show

  </tr>
<% end %>

“工作”}

下面是index.html.erb代码。


我应该怎么做才能做到这一点?这是在分析hstore字符串以在rails中显示查询结果?

您可以像访问数组一样访问数据:

<%= payment_account.data['hello'] %>

将显示
world