Add tagged_ids to taggable

Changes for queries
This commit is contained in:
chris committed 2013-05-03 16:15:37 +08:00
1 parent a4aef30a9c
commit 36da89f93e
33 files changed
+149 -227

No files matched your search

+3 -6
View File
@@ -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
+8
View File
@@ -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