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