1

I have a block of code in my view like this:

<% @map[value].each do |i| %> 

            <p><%= f.check_box(i)%> <%= f.label(i)%><br /><p>
            <% end %>

The value 'i' is having string like a_b_c. But it is displayed as a b c without underscores on the view. Please let me know how to print the string as it is on the page without trimming the underscores. Also please let me know why f.label is trimming the underscores. Thanks

user1455116
  • 2,034
  • 4
  • 24
  • 48

1 Answers1

2

label is helpful for 80% of the cases where you pass it a property symbol, which will often contain underscores. It strips out the underscores when generating the label text because most of the time you don't want the label to read something like First_Name.

You can pass a string as a second argument to override what the text of the label appears as.

<%= f.label(i, "a_b_c") %>

So maybe you can try something like this?

<%= f.label(i, i) %>
Chris Peters
  • 17,918
  • 6
  • 49
  • 65