Sha256: 90c9d4718961cf3c76892ba9475353193a159aace2c20e1de5aa237daa5fda19

Contents?: true

Size: 511 Bytes

Versions: 4

Compression:

Stored size: 511 Bytes

Contents

# frozen_string_literal: true

class Tag < ActiveRecord::Base
  has_many :taggings
  has_many :taggables, through: :taggings
  has_one  :tagging

  has_many :tagged_posts, through: :taggings, source: "taggable", source_type: "Post"
end

class OrderedTag < Tag
  self.table_name = "tags"

  has_many :ordered_taggings, -> { order("taggings.id DESC") }, foreign_key: "tag_id", class_name: "Tagging"
  has_many :tagged_posts, through: :ordered_taggings, source: "taggable", source_type: "Post"
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ibm_db-5.5.0-x86-mingw32 test/models/tag.rb
ibm_db-5.4.1-x86-mingw32 test/models/tag.rb
ibm_db-5.4.0-x86-mingw32 test/models/tag.rb
ibm_db-5.3.2-x86-mingw32 test/models/tag.rb