Sha256: f5257e58e10bf64bc39a964edfea2430a8231791f256b610a9b8839c16aa06db

Contents?: true

Size: 588 Bytes

Versions: 4

Compression:

Stored size: 588 Bytes

Contents

# this is needed for now to make mass assignment security compatible with the translation of globalize3
# Globalize::ActiveRecord::Translation.class_eval do
#   attr_accessible :locale
# end

class Tag < ActiveRecord::Base

  has_many :taggings
  has_many :pages, through: :taggings

  translates :name

  scope :alphabetically, -> { order('name') }

  def to_param
    name ? "#{id}-#{name.to_url}" : id
  end

  def self.with_taggings
    taggings = Tagging.select("DISTINCT tag_id")
    ids = taggings.map { |tagging| tagging.tag_id }
    tags = Tag.order('name').find(ids)
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tkh_content-0.9.12 app/models/tag.rb
tkh_content-0.9.11 app/models/tag.rb
tkh_content-0.9.10 app/models/tag.rb
tkh_content-0.9.9 app/models/tag.rb