开发者

Eager loading for globalize2 translations

开发者 https://www.devze.com 2022-12-22 05:11 出处:网络
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

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 = Issu开发者_运维百科e.find(params[:id])
@answers = @issue.answers

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

How can i optimize it?


Solved with

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


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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号