0
我在我的電影節和提交申請中有模型。每個作品屬於一個節日。我有一個幫手,根據每個節日的日期確定什麼是「current_festival」。只顯示當前電影節的提交內容
module ApplicationHelper
def current_festival
@current_festival ||= Festival.current.first
end
end
.current是在節日模型範圍:
scope :current, where("published = true and closing_date >= ?", Time.now.to_date).order('closing_date asc').limit(1)
我想什麼是限制在索引視圖中顯示該只屬於當前節日的人的意見。你如何在控制器中做到這一點?或者最好在模型中以某種方式做到這一點,也許通過一個範圍?
嗯,我認爲實際_scope_可能會返回節項_collection_甚至如果它是一個節日項目的集合,那麼如果上述代碼失敗,請嘗試以下操作:'Festival.current.first.submissions' – fguillen