0

I have implemented a 5 star rating system in rails and am using fontawesome stars as my labels, so would like to remove the default label text "Ratings" which is popping up between the stars.

I am able to customize the text through the quotes, but when I leave a space as I have below, it doesn't produce a space as intended but reverts back to default behavior:

 <%= form_for order do |f| %>
      <%= f.radio_button :rating, "5", class: "star-rating__input" %>
      <%= f.label :rating, ' ', title: "Rocks!", class: "star-rating__ico fa fa-star-o fa-lg" %>
      <%= f.radio_button :rating, "4", class: "star-rating__input" %>
      <%= f.label :rating, ' ', title: "Pretty good", class: "star-rating__ico fa fa-star-o fa-lg" %>
      <%= f.radio_button :rating, "3", class: "star-rating__input" %>
      <%= f.label :rating, ' ', title: "Meh", class: "star-rating__ico fa fa-star-o fa-lg" %>
      <%= f.radio_button :rating, "2", class: "star-rating__input" %>
      <%= f.label :rating, ' ', title: "Kinda bad", class: "star-rating__ico fa fa-star-o fa-lg" %>
      <%= f.radio_button :rating, "1", class: "star-rating__input" %>
      <%= f.label :rating, ' ', title: "Sucks!", class: "star-rating__ico fa fa-star-o fa-lg" %>
      <div class="clearfix"></div>
      <%= f.submit "Rate", class: "hidden btn btn-xs", id: "ratings-submit" %>
 <% end %>

I have tried the following with no success:

<%= f.label :rating, '   ', title: "Rocks!", class: "star-rating__ico fa fa-star-o fa-lg" %>

<%= f.label :rating, '" "', title: "Rocks!", class: "star-rating__ico fa fa-star-o fa-lg" %>

<%= f.label :rating, "&nbsp;", title: "Rocks!", class: "star-rating__ico fa fa-star-o fa-lg" %>

<%= f.label :rating, "#{ }", title: "Rocks!", class: "star-rating__ico fa fa-star-o fa-lg" %>

Any help would be appreciated

fool-dev
  • 7,671
  • 9
  • 40
  • 54
  • 1
    Not really, I know how to enter customer text, what I don't know is how to remove it – user3810065 May 17 '18 at 00:15
  • Can you not write some HTML instead of Ruby between the radio buttons? Or maybe using an empty block ? https://stackoverflow.com/questions/6088348/passing-block-to-label-helper-in-rails3 – Maxence May 17 '18 at 01:26

1 Answers1

0

You must use a block to enclose the label

<%= f.radio_button :rating, "5", class: "star-rating__input" %>
<%= f.label :rating do %>
  <i class="star-rating__ico fa fa-star-o fa-lg"></i>
<%- end -%>

or you can use label_tag

<%= f.radio_button :rating, "5", class: "star-rating__input" %>
<%= label_tag :rating, '', class: "star-rating__ico fa fa-star-o fa-lg"%>
Andres23Ramirez
  • 647
  • 1
  • 4
  • 14