Sha256: 12d2125534347aeb551081d4d2d860b14c8868fd95dc291e0f11df89a059c887

Contents?: true

Size: 671 Bytes

Versions: 7

Compression:

Stored size: 671 Bytes

Contents

# == Schema Information
#
# Table name: lentil_tags
#
#  id         :integer          not null, primary key
#  name       :string(255)
#  created_at :datetime         not null
#  updated_at :datetime         not null
#

class Lentil::Tag < ActiveRecord::Base
  attr_accessible :name, :staff_tag

  has_many :tagset_assignments
  has_many :tagsets, :through=>:tagset_assignments

  has_many :taggings
  has_many :images, :through=>:taggings

  validates_presence_of :name

  scope :harvestable, where(:lentil_tagsets => {:harvest => true}).includes(:tagsets)
  
  #Stripping tags on write
  def name=(new_name)
    write_attribute(:name, new_name.sub(/^#/, ''))
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lentil-0.5.2 app/models/lentil/tag.rb
lentil-0.5.1 app/models/lentil/tag.rb
lentil-0.5.0 app/models/lentil/tag.rb
lentil-0.4.2 app/models/lentil/tag.rb
lentil-0.4.0 app/models/lentil/tag.rb
lentil-0.3.1 app/models/lentil/tag.rb
lentil-0.3.0 app/models/lentil/tag.rb