Sha256: f44ce2ceeff5295d2f232bf6b95d28169a1c2a0db54a9262ca9e5d69da42d0c6

Contents?: true

Size: 545 Bytes

Versions: 5

Compression:

Stored size: 545 Bytes

Contents

class Tag < ActiveRecord::Base
  has_many :taggings
  
  validates_presence_of :name
  validates_uniqueness_of :name
  
  cattr_accessor :destroy_unused
  self.destroy_unused = false
  
  # LIKE is used for cross-database case-insensitivity
  def self.find_or_create_with_like_by_name(name)
    find(:first, :conditions => ["name LIKE ?", name]) || create(:name => name)
  end
  
  def ==(object)
    super || (object.is_a?(Tag) && name == object.name)
  end
  
  def to_s
    name
  end
  
  def count
    read_attribute(:count).to_i
  end
end

Version data entries

5 entries across 5 versions & 4 rubygems

Version Path
elight-acts_as_taggable_on_steroids-1.1 lib/tag.rb
ggoodale-acts_as_taggable_on_steroids-1.1.1 lib/tag.rb
ggoodale-acts_as_taggable_on_steroids-1.1 lib/tag.rb
rotuka-taggable-0.0.1 generators/tags/templates/tag.rb
pictrails-0.5.0 vendor/plugins/acts_as_taggable_on_steroids/lib/tag.rb