Forum: Ruby on Rails Find by time?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3319ab6fb19fcf97c8a3d66b8a9b68bf?d=identicon&s=25 Josh on Rails (Guest)
on 2006-05-03 18:57
(Received via mailing list)
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...
675475d0b65710be6d992eb5eb2c61c2?d=identicon&s=25 Gregory Seidman (Guest)
on 2006-05-03 18:57
(Received via mailing list)
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
3319ab6fb19fcf97c8a3d66b8a9b68bf?d=identicon&s=25 Josh on Rails (Guest)
on 2006-05-03 18:57
(Received via mailing list)
Thanks, that did it!
This topic is locked and can not be replied to.