28
29
30
31
32
33
34
35
36
37
|
# File 'app/models/cms/taggable.rb', line 28
def define_tag_association(assoc)
source_klass = self.to_s
Cms::Tag.class_eval do
has_many assoc, :through => :taggings, :source => :taggable, :source_type => source_klass
end
self.scope :tagged_with, lambda{|tag| {:include => :tags, :conditions => ['cms_tags.name like ?', tag.to_s]}}
self.scope :tagged, :joins => "left outer join cms_taggings on cms_taggings.taggable_id = #{table_name}.id", :conditions => 'cms_taggings.id is not null'
self.scope :untagged, :joins => "left outer join cms_taggings on cms_taggings.taggable_id = #{table_name}.id", :conditions => 'cms_taggings.id is null'
end
|