> @id = case when @recipes.length == i + 1: 0; when i.remainder(2) == 1: 
> 1; else 2 end
> 
> Although I admit that I'd rather have it on several lines

I suspect the original posted might not know you can write a multi-line
<% erb %> block! Some sample code puts a different <% %> on each line,
like the original post did...