Sha256: 2083168cbb317ab14a6ba6e90bb88692506b79b9c7133a46d6dd3fe640a0655b

Contents?: true

Size: 865 Bytes

Versions: 3

Compression:

Stored size: 865 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)
  scope :not_harvestable, where(:lentil_tagsets => {:harvest => false}).includes(:tagsets)
  scope :no_tagsets, where(:lentil_tagset_assignments => {:tag_id => nil}).includes(:tagset_assignments)

  #Stripping tags on write
  def name=(new_name)
    write_attribute(:name, new_name.sub(/^#/, ''))
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lentil-0.8.0 app/models/lentil/tag.rb
lentil-0.7.1 app/models/lentil/tag.rb
lentil-0.6.0 app/models/lentil/tag.rb