How do I access a counter inside a Ruby iteration? -


My Google skills are failing me big time if I have a standalone ruby ​​loop like this:

< Pre> & lt;% @ notes.each do | Q | & Gt%; & Lt;% end & gt;

How do I get a loop counter from the loop? Thanks for reading.

Use each instead of

each < / Code> To get the index:

  @ Notes. Note, IDX | P idx p note end  

See Ruby for more information.


Comments