0
我有一個控制器問題,旨在檢測任務/待辦事項並將其傳遞給視圖。在控制器中提供視圖內容
在我的應用程序佈局我有一個預留空間,以使這些任務
<%= yield(:tasks) if content_for?(:tasks) %>
這裏是我包括ApplicationController中的模塊。它似乎沒有正常工作和content_for?(:tasks)
返回false(byebug說)
module TaskControl
extend ActiveSupport::Concern
included do
before_action :check_tasks
def check_tasks
if user_signed_in? and current_user.tasks.todos.any?
# TODO : better task strategy afterwards
view_context.provide(:tasks,
view_context.cell(:tasks, current_user.tasks.todos.first)
)
end
view_context.content_for?(:tasks) # => false :'(
end
end
end
請注意,我沒有用byebug檢查,
view_context.cell(:tasks, current_user.tasks.todos.first).blank? # => false, so there is something to render