Array::index broken

Is there a way to call Array::index in Rails???

This is what I want to do:

@photos.map do |value|       @photos.index(value)%5 == 0 ? (@sorted_photos[i += 1] ||= ) << value : (@sorted_photos[i] ||= ) << value     end

However Rails is hijacking the index method call and breaking.

It would appear you can't call each_with_index from a controller either. Is there any way to actually do this?

Quoting Glen <DamnBigMan@gmail.com>:

It would appear you can't call each_with_index from a controller either. Is there any way to actually do this?

> Is there a way to call Array::index in Rails??? > > This is what I want to do: > > @photos.map do |value| > @photos.index(value)%5 == 0 ? (@sorted_photos[i += 1] ||= ) << > value : (@sorted_photos[i] ||= ) << value > end > > However Rails is hijacking the index method call and breaking.

Array::each_index() works for me in a model. Are you sure of operator precedence and grouping? Try fully parenthesizing the expressions.

Jeffrey

My fault. I was forgetting to set @sorted_photos ||= .