Skip to content

Commit

Permalink
count fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jywarren committed Aug 4, 2020
1 parent fae8c66 commit 243e405
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions app/models/node_tag.rb
Expand Up @@ -8,13 +8,11 @@ class NodeTag < ApplicationRecord
has_many :tag_selections, foreign_key: 'tid'
accepts_nested_attributes_for :tag

after_create :increment_count
after_create :update_count
after_destroy :update_count

def increment_count
tag = self.tag
tag.count = 0 if tag.count.nil?
tag.count += 1
tag.save
def update_count
tag.run_count # update count of tag usage
end

def user
Expand Down

0 comments on commit 243e405

Please sign in to comment.