views:

153

answers:

2

Hi, i have 2 models - Issue and Answers (issue has many answers) and both have translations with globalize2. Every time i attempting to load Issue with answers via

@issue = Issue.find(params[:id])
@answers = @issue.answers

causes loading of translations for each Answer (1 sql query per Answer).

How can i optimize it?

A: 

@answers = @issue.answers.all(:include => :answer_translations)

mikhailov
Association named 'answer_translations' was not found; perhaps you misspelled it?
Alexey Poimtsev
A: 

Solved with

@answers = @issue.answers.all(:include => :translations)
Alexey Poimtsev