If I want to reload an AR association, I can call "reload" on it. department.employees.reload or what have you. But what I want to do is uncache it, but not actually take a trip to the db. I want to mark it so NEXT time it''s accessed, it will take a trip to the db (if it is ever accessed again). I know it''s become unreliable, but I don''t want to spend the time reloading it now, I want to just mark it as uncached. Lazily reload it. Any good way to do that in AR? -- 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 7 May 2008, at 21:25, Jonathan Rochkind wrote:> > If I want to reload an AR association, I can call "reload" on it. > department.employees.reload or what have you. > > But what I want to do is uncache it, but not actually take a trip to > the > db. I want to mark it so NEXT time it''s accessed, it will take a > trip to > the db (if it is ever accessed again). I know it''s become unreliable, > but I don''t want to spend the time reloading it now, I want to just > mark > it as uncached. Lazily reload it. >If it''s an association collection, then department.employees.reset should do the trick. For has_one/belongs_to you need to fiddle with innards. Fred> Any good way to do that in AR? > -- > 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 -~----------~----~----~----~------~----~------~--~---
Perfect, that meets my present needs, thanks. Would be a useful enhancement to support reset/reload on to-one relationships too, but for now this is what I need, thanks. Frederick Cheung wrote:> On 7 May 2008, at 21:25, Jonathan Rochkind wrote: > >> mark >> it as uncached. Lazily reload it. >> > > If it''s an association collection, then department.employees.reset > should do the trick. For has_one/belongs_to you need to fiddle with > innards. > > 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 -~----------~----~----~----~------~----~------~--~---