Tip: Use Rails `cycle` to avoid `i % 2 == 0` in your view loops

Sometimes you need to keep track of how many times you’ve looped when rendering some views, for instance to alternate background colors to create a “striped”.Sometimes you need to keep track of how many times you’ve looped when rendering some views, for instance to alternate background colors to create a “striped” table.


Tip: Use Rails `cycle` to avoid `i % 2 == 0` in your view loops #ruby #rubydeveloper #rubyonrails https://rubyonrails.ba/single/boring-rails-skip-the-bullshit-and-ship-fast

Nezir Zahirovic

Contractor Ruby On Rails (8+ years) / MCPD .Net / C# / Asp.Net / CSS / SQL / (11 years)

related articles