# Is rails caching my date

**URL:** <https://www.ruby-forum.com/t/is-rails-caching-my-date/113448>\
**Category:** Rails\
**Created:** [August 31, 2007, 4:27am UTC](https://www.ruby-forum.com/t/is-rails-caching-my-date/113448 "2007-08-31T04:27:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yannimac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/7993a0/32.png) [@yannimac](https://www.ruby-forum.com/u/yannimac)\
**Post date:** [August 31, 2007, 4:27am UTC](https://www.ruby-forum.com/t/is-rails-caching-my-date/113448/1 "2007-08-31T04:27:40Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![yannimac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/7993a0/32.png) [@yannimac](https://www.ruby-forum.com/u/yannimac)\
**Post date:** [August 31, 2007, 10:08am UTC](https://www.ruby-forum.com/t/is-rails-caching-my-date/113448/2 "2007-08-31T10:08:48Z")

</div>

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
