How do I descent from 5 to 1 instead of going from 1 to 5? I have this...
<div class="field-container rating">
<% (5..1).each do |i| %>
<%= f.radio_button :rating, i, :id => "star#{i}" %>
<% end %>
</div>
(1..5)
goes from 1, 2, 3, 4, 5. What is the correct way of going 5, 4, 3, 2, 1?
You can do downto
<div class="field-container rating">
<% 5.downto(1) do |i| %>
<%= f.radio_button :rating, i, :id => "star#{i}" %>
<% end %>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With