# ActiveRecord association lazy reload?

**URL:** <https://www.ruby-forum.com/t/activerecord-association-lazy-reload/136984>\
**Category:** Rails\
**Created:** [May 7, 2008, 10:25pm UTC](https://www.ruby-forum.com/t/activerecord-association-lazy-reload/136984 "2008-05-07T22:25:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jrochkind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/779978/32.png) [@jrochkind](https://www.ruby-forum.com/u/jrochkind)\
**Post date:** [May 7, 2008, 10:25pm UTC](https://www.ruby-forum.com/t/activerecord-association-lazy-reload/136984/1 "2008-05-07T22:25:09Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jrochkind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/779978/32.png) [@jrochkind](https://www.ruby-forum.com/u/jrochkind)\
**Post date:** [May 7, 2008, 11:01pm UTC](https://www.ruby-forum.com/t/activerecord-association-lazy-reload/136984/2 "2008-05-07T23:01:30Z")

</div>

On 7 May 2008, at 21:25, Jonathan R. 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

---

<div class="post-metadata">

**Author:** ![jrochkind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/779978/32.png) [@jrochkind](https://www.ruby-forum.com/u/jrochkind)\
**Post date:** [May 7, 2008, 11:05pm UTC](https://www.ruby-forum.com/t/activerecord-association-lazy-reload/136984/3 "2008-05-07T23:05:19Z")

</div>

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 C. wrote:

> On 7 May 2008, at 21:25, Jonathan R. 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
