Move to scope and inline method
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 %>
|
||||
Reference in New Issue
Block a user