diff --git a/app/models/project.rb b/app/models/project.rb index 3d1a552..fcfc2c9 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -3,6 +3,8 @@ class Project < ApplicationRecord validates :name, presence: true + broadcasts_refreshes + def completed? tasks.pending.none? end diff --git a/app/models/task.rb b/app/models/task.rb index 4b35aaf..ed5f146 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -1,5 +1,5 @@ class Task < ApplicationRecord - belongs_to :project + belongs_to :project, touch: true scope :completed, -> { where(completed: true) } scope :pending, -> { where(completed: false) } diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb index 9f10f93..1fde195 100644 --- a/app/views/projects/index.html.erb +++ b/app/views/projects/index.html.erb @@ -1,3 +1,7 @@ +<% @projects.each do |project| %> + <%= turbo_stream_from project %> +<% end %> +