0
我不確定是否每次調用current_brain.current_vocab_badge
時,都會有一個單獨的數據庫調用。如何保存到數據庫的點擊
如果我有這樣的:
max_prog = (current_brain.current_vocab_badge.topic.words.count * 2)
comp_prog = current_brain.current_vocab_badge.questions.where('style != ?', 'VisualPrereq').select{|q| q.weakness.blank? }.size
{ totes_left: remaining_prog, totes_so_far: comp_prog, cur_badge: current_brain.current_vocab_badge.name }
那是要進行3個獨立的調用數據庫的current_brain.current_vocab_badge
其中current_brain
在我application_controller實例爲:
def current_brain
current_user.brain
end
如果是的話它是否有助於創建它的一個實例變量,然後引用該變量,或者我的application_controller已經實現了該變量?
輝煌,謝謝! – Trip