Reputation: 7
I am iterating over a Hashmap of type . Works pretty well. My problem is, it prints out the whole Hashmap as String after the wanted output.
What is happening? How can i prevent my app from doing that?
Edit: sorry for being silly.. totally forgot that!
source-code:
<div style="display: inline-block">
<%= @tag_color_hash.each do |tag, color| %>
<%= f.label tag, :style => "border-color: #{color}", :class => 'tags'%>
<% end %>
</div>
Upvotes: 0
Views: 126
Reputation: 2162
You're getting this because you've included a =
sign in your .each
loop. When you write <%=
you're telling the .erb
interpreter that what's inside of the brackets is going to get displayed on the page. Change the line
<%= @tag_color_hash.each do |tag, color| %>
to
<% @tag_color_hash.each do |tag, color| %>
and your problem should get fixed. Here's a link to a useful StackOverflow answer.
Upvotes: 1