Sha256: 145516880485b5423a55debf8ac8d15459bf6e66f00a52baf72aad35ced09e98
Contents?: true
Size: 678 Bytes
Versions: 2
Compression:
Stored size: 678 Bytes
Contents
class Gutentag::Tag < ActiveRecord::Base self.table_name = 'gutentag_tags' has_many :taggings, :class_name => 'Gutentag::Tagging', :dependent => :destroy attr_accessible :name if Rails.version.to_s < '4.0.0' scope :by_weight, ->{ order('gutentag_tags.taggings_count DESC') } validates :name, :presence => true, :uniqueness => {:case_sensitive => false} before_validation :normalise_name 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 private def normalise_name self.name = Gutentag.normaliser.call name end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gutentag-0.6.0 | app/models/gutentag/tag.rb |
gutentag-0.5.1 | app/models/gutentag/tag.rb |