I have this super simple code in my view:
<% @something.each do |something| %>
<% i = i+1 %>
<div class="row">
<div class="span1"><span class="badge untouched"><%= i %></span></div>
</div>
<% end %>
and get this error
undefined method `+' for nil:NilClass
I have the exact same code in another view and there it works! However, I'm new to rails and you see what I want to do. Maybe there is a more common way to increment an integer within an each loop? Where does this error come from?
Thanks for any help!
Well, i must have a value before you can increment it.
<% i = 0 %>
<% i = i+ 1 %>
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