Hi Yanni
Date.today.to_s will give you what you want for today. "2007-08-31"
How about trying:
@items = Item.find(:all, :conditions => [''expiration >=
?'',Date.today]) -
thats if your date column is a datetime field.
Regards
Ivor
On 8/31/07, Yanni Mac
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
>
> I have an app that is supposed to expire items based on a comparison of
> the expiration date of the item and the current date. So if expiration
> date < current date, I do not want to display the item. Rails seems to
> be caching something, because the variable I set for the current date is
> from a few days back - when I restart mongrel it must release the cache
> because it expires my items as it should. Here is what I have in my
> controller:
>
> def list_items
> today =
Time.now.beginning_of_day.to_date.strftime("%Y-%m-%d")
> @items = Item.find(:all,:conditions =>
"expiration>=''#{today}''")
> end
>
> How can I stop rails from caching @today?
> --
> Posted via http://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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---