# Weird active record problem - goes away with cache\_classes change

**URL:** <https://discuss.rubyonrails.org/t/weird-active-record-problem-goes-away-with-cache-classes-change/18851>\
**Category:** rubyonrails-talk\
**Created:** [October 4, 2007, 1:12am UTC](https://discuss.rubyonrails.org/t/weird-active-record-problem-goes-away-with-cache-classes-change/18851 "2007-10-04T01:12:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anand\_Sankaran](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@Anand\_Sankaran](https://discuss.rubyonrails.org/u/Anand_Sankaran)\
**Post date:** [October 4, 2007, 1:12am UTC](https://discuss.rubyonrails.org/t/weird-active-record-problem-goes-away-with-cache-classes-change/18851/1 "2007-10-04T01:12:40Z")

</div>

I have three active record objects, User, Question and Answer

- Questions belong to a user and has\_many answers - Answer belongs to a user

Now, when I start with an array of answers, I can do this successfully:

for a in answers &nbsp;&nbsp;a.user.user\_id end

If I do this:

for q in questions &nbsp;&nbsp;answers = q.answers &nbsp;&nbsp;for a in answers &nbsp;&nbsp;&nbsp;&nbsp;a.user.user\_id &nbsp;&nbsp;end end

It works the first time, but it fails the 2nd time on with this:

ActionView::TemplateError (undefined method `user' for #\<Answer: 0x351617c\>) on line #45 of app/views/lib/\_qnalist.rhtml: 42: \<div class="qna-a- details"\> 43: \<span class="qna-a-body"\>\<%= format\_line\_wrap(a.body, width, 14) %\>\</

> \<br\>

44: \<span class="qna-a-info"\> 45: Answered by \<%= a.user.user\_id %\> - \<%= a.created\_at %\> 46: \</span\> 47: \</div\> 48: \<div class="very- narrow-space"\>&nbsp\</div\>

However, this is fixed IF I change development.rb and change cache\_classes to true

config.cache\_classes = true

I have no clue what is happening :(.

Any one knows how to fix this?
