Reputation: 2866
<% @challenge.days_challenged.times do %>
<div class="text-background">
Day <%= + 1 %>
<%= render "notes/notes" %>
<%= render "notes/form" %>
</div>
<% end %>
Every note has "Day 1" at the top instead of "Day 1", "Day 2", "Day 3", etc depending on how many @challenge.days_challenged
Upvotes: 0
Views: 140
Reputation: 36004
Assuming days_challenged#times
is an array of the days...
days_challenged.times.each do |day|
puts "Day #{day}"
end
outputs each day
Upvotes: 2
Reputation: 11823
Use counter like so:
<% @challenge.days_challenged.times do |counter| %>
<div class="text-background">
Day <%= counter + 1 %>
<%= render "notes/notes" %>
<%= render "notes/form" %>
</div>
<% end %>
Here, .times
would pass the current step of the iteration starting from 0 to your block.
Upvotes: 4