fr0styy
fr0styy

Reputation: 7

whole RUBY hashmap printed out after ".each" loop

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.

Screenshot

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

Answers (1)

gr1zzly be4r
gr1zzly be4r

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

Related Questions