Skip to content

Commit

Permalink
convert tag.category to a regular association
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrock committed Apr 2, 2018
1 parent ced9187 commit 3a974ad
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 1 addition & 5 deletions app/models/tag.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Tag < ApplicationRecord
has_many :taggings, :dependent => :destroy
has_one :classification
virtual_has_one :category, :class_name => "Classification"
has_one :category, :through => :classification, :source => :parent
virtual_has_one :categorization, :class_name => "Hash"

has_many :container_label_tag_mappings
Expand Down Expand Up @@ -133,10 +133,6 @@ def ==(comparison_object)
super || name.downcase == comparison_object.to_s.downcase
end

def category
@category ||= Classification.find_by_name(name_path.split('/').first, nil)
end

def show
category.try(:show)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def mapped_tag(category_name, tag_name)
mapping = FactoryGirl.create(:tag_mapping_with_category,
:category_name => category_name,
:category_description => category_name)
category = mapping.tag.category
category = mapping.tag.classification
entry = category.add_entry(:name => tag_name, :description => tag_name)
entry.tag
end
Expand Down

0 comments on commit 3a974ad

Please sign in to comment.