Reputation: 19969
I'd like to do the following:
<% tags=[{"2":"birds"},{"3":"cars"}] %>
<% tags.each do |key, value| %>
<%=key %> <%=value %>
<% end %>
but this doesn't work. How would I do this (if possible)?
Upvotes: 1
Views: 169
Reputation: 1147
Since each hash can have any number of key/value pairs:
<% tags=[{"2":"birds"},{"3":"cars"}] %>
<% tags.each do |t| %>
<% t.each do |key,value| %>
<%=key %> <%=value %>
<% end %>
<% end %>
Upvotes: 4