how iterating through serialized hash and show just keys on the view?
policy model
class Policy < ActiveRecord::Base
belongs_to :user
serialize :shipping, JSON
end
index
<% @policy.shipping.each do |key, value|%>
<ul><li><%= key %></li></ul>
<% end %>
Hash has a
keysmethod, which returns its keys. So you can do the same with the following code:You should also note that the
<ul>tag should not be inside the loop.