Sha256: c9a9fd69d1f7eeae55632ac6a7d6ee4d1c784bd264521c8b7cf2e0ce6bd76645

Contents?: true

Size: 590 Bytes

Versions: 5

Compression:

Stored size: 590 Bytes

Contents

# frozen_string_literal: true

class Gutentag::Tag < ActiveRecord::Base
  self.table_name = "gutentag_tags"

  has_many :taggings,
    :class_name => "Gutentag::Tagging",
    :dependent  => :destroy

  attr_accessible :name if ActiveRecord::VERSION::MAJOR == 3

  scope :by_weight, lambda { order("gutentag_tags.taggings_count DESC") }

  def self.find_by_name(name)
    where(:name => Gutentag.normaliser.call(name)).first
  end

  def self.find_or_create(name)
    find_by_name(name) || create(:name => name)
  end

  def name=(value)
    super(Gutentag.normaliser.call(value))
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gutentag-2.3.2 app/models/gutentag/tag.rb
gutentag-2.3.1 app/models/gutentag/tag.rb
gutentag-2.3.0 app/models/gutentag/tag.rb
gutentag-2.2.1 app/models/gutentag/tag.rb
gutentag-2.2.0 app/models/gutentag/tag.rb