Sha256: a6146bbccd4e52b544b21f144fcd4e438cc4b7ae90481d21b062c9a0b7303f09

Contents?: true

Size: 612 Bytes

Versions: 20

Compression:

Stored size: 612 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, :dependent => :destroy
  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

20 entries across 20 versions & 1 rubygems

Version Path
tkh_content-0.10.10 app/models/tag.rb
tkh_content-0.10.9 app/models/tag.rb
tkh_content-0.10.8 app/models/tag.rb
tkh_content-0.10.7 app/models/tag.rb
tkh_content-0.10.6 app/models/tag.rb
tkh_content-0.10.5.1 app/models/tag.rb
tkh_content-0.10.5 app/models/tag.rb
tkh_content-0.10.4 app/models/tag.rb
tkh_content-0.10.3 app/models/tag.rb
tkh_content-0.10.2 app/models/tag.rb
tkh_content-0.10.1 app/models/tag.rb
tkh_content-0.10 app/models/tag.rb
tkh_content-0.9.20 app/models/tag.rb
tkh_content-0.9.19 app/models/tag.rb
tkh_content-0.9.18 app/models/tag.rb
tkh_content-0.9.17 app/models/tag.rb
tkh_content-0.9.16 app/models/tag.rb
tkh_content-0.9.15 app/models/tag.rb
tkh_content-0.9.14 app/models/tag.rb
tkh_content-0.9.13 app/models/tag.rb