Sha256: e95b07fdcc0a3054e9d1ad0aa56d7898f6af27252fd50d15e7b83ace797a5c98

Contents?: true

Size: 897 Bytes

Versions: 2

Compression:

Stored size: 897 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

  stores_emoji_characters :name
  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

2 entries across 2 versions & 1 rubygems

Version Path
lentil-0.9.1 app/models/lentil/tag.rb
lentil-0.9.0 app/models/lentil/tag.rb