Add tagged_ids to taggable
Changes for queries
This commit is contained in:
1 parent
a4aef30a9c
commit
36da89f93e
33 files changed
+149
-227
No files matched your search
+3
-6
@@ -2,6 +2,8 @@ class Asset
|
||||
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
include OrbitTag::Taggable
|
||||
taggable
|
||||
|
||||
mount_uploader :data, FileAssetUploader
|
||||
|
||||
@@ -16,18 +18,13 @@ class Asset
|
||||
|
||||
belongs_to :asset_category
|
||||
belongs_to :assetable, polymorphic: true
|
||||
has_and_belongs_to_many :tags, :class_name => "AssetTag"
|
||||
|
||||
before_save :clean_tags
|
||||
|
||||
def sorted_tags
|
||||
tags.order_by(I18n.locale, :asc)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def clean_tags
|
||||
self.tag_ids.delete('')
|
||||
self.tagged_ids.delete('')
|
||||
end
|
||||
|
||||
end
|
||||
@@ -6,4 +6,12 @@ class Tagging
|
||||
|
||||
belongs_to :tag
|
||||
belongs_to :taggable, polymorphic: true
|
||||
|
||||
before_destroy :update_taggable_tag_ids
|
||||
|
||||
private
|
||||
|
||||
def update_taggable_tag_ids
|
||||
self.taggable.remove_id(self.tag.id)
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user