Thanks Robert, yeah that's a silly thing to do :)

Colin I'll try doing the :conditions => [ 'timestamp >= ? and
timestamp <= ?', timestamp1, timestamp2 ] and see how it performs
thanks I should have thought of doing that.

radhames yeah it makes a lot more sense to do it in the db, just wrote
some code quickly to do it in ruby land to see if it was possible

I'll post up the finished code when I'm done for future reference if
anyone else finds themselves in the same pickle



On Sep 9, 10:21 pm, Robert Walker <li...@ruby-forum.com> wrote:
> voidstar wrote:
> >  def FilterUtils.apply_year_filter readings, years
> >     readings.each {|reading|
> >       if( reading.timestamp != nil && years != nil &&
> > years.index(reading.timestamp.year) == nil )
> >         readings.delete(reading)
> >       end
> >     }
> >     readings
> >   end
>
> I realize that you're not actually planning to use this code (thank
> goodness), but I just wanted to point out that you're mutating the array
> your iterating over. This is a VERY bad idea generally speaking.
> --
> Posted viahttp://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to