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

**URL:** <https://www.ruby-forum.com/t/weird-active-record-problem-goes-away-with-cache-classes-change/116283>\
**Category:** Rails\
**Created:** [October 4, 2007, 3:13am UTC](https://www.ruby-forum.com/t/weird-active-record-problem-goes-away-with-cache-classes-change/116283 "2007-10-04T03:13:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Obelix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/e68b1a/32.png) [@Obelix](https://www.ruby-forum.com/u/Obelix)\
**Post date:** [October 4, 2007, 3:13am UTC](https://www.ruby-forum.com/t/weird-active-record-problem-goes-away-with-cache-classes-change/116283/1 "2007-10-04T03:13:26Z")

</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  
a.user.user\_id  
end

If I do this:

for q in questions  
answers = q.answers  
for a in answers  
a.user.user\_id  
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:

  
43: \<%= format\_line\_wrap(a.body, width, 14) %\>\</  
span\>  
  
44:   
45:  
Answered by \<%= a.user.user\_id %\> - \<%= a.created\_at %\>  
46:   
47: 
  
48: 
&nbsp

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?
