Sha256: ea454ae0062b3d9d1ba90ef845f87e86ae342568e2c66177544cad48330206f7
Contents?: true
Size: 699 Bytes
Versions: 9
Compression:
Stored size: 699 Bytes
Contents
class Blog::Tagging < ActiveRecord::Base self.table_name = :blog_taggings # -- Relationships -------------------------------------------------------- belongs_to :post belongs_to :tag, :counter_cache => true # -- Callbacks ------------------------------------------------------------ after_destroy :destroy_tag # -- Scopes --------------------------------------------------------------- scope :for_tags, includes(:tag).where('blog_tags.is_category' => false) scope :for_categories, includes(:tag).where('blog_tags.is_category' => true) protected def destroy_tag self.tag.destroy if !self.tag.is_category? && self.tag.taggings.count == 0 end end
Version data entries
9 entries across 9 versions & 1 rubygems