Skip to content

Commit

Permalink
Broadcasts
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgemanrubia committed Nov 27, 2023
1 parent f7b5a6f commit babd679
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ class Project < ApplicationRecord

validates :name, presence: true

broadcasts_refreshes

def completed?
tasks.pending.none?
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/task.rb
Original file line number Diff line number Diff line change
@@ -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) }
Expand Down
4 changes: 4 additions & 0 deletions app/views/projects/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<% @projects.each do |project| %>
<%= turbo_stream_from project %>
<% end %>

<h1 class="title">
You have <span><%= @projects.count %> </span> projects:
</h1>
Expand Down
2 changes: 2 additions & 0 deletions app/views/projects/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<%= turbo_stream_from @project %>

<nav class="breadcrumb" aria-label="breadcrumbs">
<ul>
<li>
Expand Down

0 comments on commit babd679

Please sign in to comment.