Find by time?

I’m trying to find events created after an initial date. I’m sure it’s
something obvious, but I’m not sure why this isn’t working:

def self.find_recent
find(:all, :conditions=>“created_at > #{Time.local(2006, 4, 27, 22,
0, 0)}”)
end

Time for more caffeine for me…

On Mon, May 01, 2006 at 07:26:56AM -0400, Josh on Rails wrote:
} I’m trying to find events created after an initial date. I’m sure it’s
} something obvious, but I’m not sure why this isn’t working:
}
} def self.find_recent
} find(:all, :conditions=>“created_at > #{Time.local(2006, 4, 27, 22,
0,
} 0)}”)
} end

Try this:

def self.find_recent
find(:all, :conditions => [‘created_at > ?’, Time.local(2006, 4, 27,
22, 0, 0)])
end

The string substitution is not really what you want.

–Greg

Thanks, that did it!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs