Sha256: d34553d7abe0e94280d26f772e3f582132ffc8beb127e9d65d4691b452acd0ca

Contents?: true

Size: 579 Bytes

Versions: 2

Compression:

Stored size: 579 Bytes

Contents

class Tag < ActiveRecord::Base
  has_many :taggings, :dependent => :destroy

  validates_presence_of :name
  validates_uniqueness_of :name, :scope => [:project_id, :kind]

  scope :with_name_like_and_kind_and_project_id, lambda { |name, kind, project_id| where("project_id = ? AND name like ? AND kind = ?", project_id, name, kind) }
  scope :of_kind,                 lambda { |kind| where(:kind => kind) }
  
  def decrement_taggings_count!
    self.taggings_count -= 1
    self.save
  end
  
  def increment_taggings_count!
    self.taggings_count += 1
    self.save
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
edouard-is_taggable-0.1.3 lib/tag.rb
edouard-is_taggable-0.1.1 lib/tag.rb