Move to scope and inline method

This commit is contained in:
Jason Zimdars
2025-07-02 16:14:25 -05:00
parent 27aaa815c7
commit aff0a38b37
3 changed files with 3 additions and 5 deletions
-4
View File
@@ -4,8 +4,4 @@ module Card::Multistep
included do
has_many :steps, dependent: :destroy
end
def completed_steps_count
steps.where(completed: true).count
end
end
+2
View File
@@ -1,6 +1,8 @@
class Step < ApplicationRecord
belongs_to :card, touch: true
scope :completed, -> { where(completed: true) }
def completed?
completed
end
@@ -3,6 +3,6 @@
<span class="steps__icon">
<%= icon_tag "check" %>
</span>
<strong><%= "#{card.completed_steps_count}/#{card.steps.count}" %></strong>
<strong><%= "#{card.steps.completed.count}/#{card.steps.count}" %></strong>
</div>
<% end %>