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: <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"> </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?