简体   繁体   中英

how do I display the in views this hash?

how do I display the in views this hash?

class Credit < ActiveRecord::Base
  serialize :credit_data
end

I got the hash, but I can't display it in views.

=> [#<Credit:0x00000005d49900
  id: 18,
  credit_data:
   {3000=>[{1=>492}, {2=>984}, {3=>1536}, {4=>2136}, {5=>2760}],
    4000=>[{1=>656}, {2=>1328}, {3=>2048}, {4=>2816}, {5=>3620}],
    5000=>[{1=>820}, {2=>1648}, {3=>2560}, {4=>3544}, {5=>4540}],
    ........
  created_at: Wed, 04 Mar 2015 14:22:59 UTC +00:00,
  updated_at: Wed, 04 Mar 2015 14:22:59 UTC +00:00>]

I am not sure but you can try something like this

<table>
    <tr>
        <% credit_data.each do |k,v| %>
            <th><%= k %></th>
            <% v.each do |v1| %>
                <td><%= v1.values %></td> 
            <% end %>
        <% end %>
    </tr>
</table>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM