Ich habe eine Controller-Anliegen, die auf die Erkennung und Weitergabe von Aufgaben/Todos auf die Ansicht zielt.Anzeigen Inhalt in Controller
In meiner Anwendung Layout Ich habe einen reservierten Platz diese Aufgaben
<%= yield(:tasks) if content_for?(:tasks) %>
Hier ist das Modul, das ich in Applicationcontroller enthalten zu machen. Es scheint nicht richtig funktioniert und die content_for?(:tasks)
false zurück (byebug sagt)
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
Bitte beachte, dass ich mit byebug überprüfen hat,
view_context.cell(:tasks, current_user.tasks.todos.first).blank? # => false, so there is something to render