I have an object that has_many widgets, but I only want the widgets that are not expired associated with this object. My app is showing widgets that are expired, so the date must be getting cached. Anyone got a simple workaround for this? Is there some way to expire the cache every 24 hours, or force it to use the current Time.now every time it looks at this association? Any help would be greatly appreciated. I could check it in the view or the controller but that seems like a pretty messy solution. Let me know if you all have any ideas. Thanks!! has_many :widgets, :conditions => "expiration>=''#{Time.now.beginning_of_day.strftime("%Y-%m-%d")}''" -- 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 -~----------~----~----~----~------~----~------~--~---
Note: I am using rails version 1.2.3 -- 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 -~----------~----~----~----~------~----~------~--~---
On 16 Apr 2009, at 14:53, Yanni Mac wrote:> > I have an object that has_many widgets, but I only want the widgets > that > are not expired associated with this object. My app is showing > widgets > that are expired, so the date must be getting cached. Anyone got a > simple workaround for this? Is there some way to expire the cache > every > 24 hours, or force it to use the current Time.now every time it > looks at > this association? Any help would be greatly appreciated. I could > check > it in the view or the controller but that seems like a pretty messy > solution. Let me know if you all have any ideas. Thanks!! > > has_many :widgets, :conditions => > "expiration>=''#{Time.now.beginning_of_day.strftime("%Y-%m-%d")}''"Caching isn''t really what''s happening. That line is evaluated precisely once, and so that string interpolation happens once. I wrote a bit about this and similar problems at http://www.spacevatican.org/2008/11/9/do-you-know-when-your-code-runs Fred> > -- > 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 -~----------~----~----~----~------~----~------~--~---
You are the man Fred! Exactly what I needed. Thanks!! -- 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 -~----------~----~----~----~------~----~------~--~---