aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/tag.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/models/tag.rb')
-rw-r--r--activerecord/test/models/tag.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/activerecord/test/models/tag.rb b/activerecord/test/models/tag.rb
new file mode 100644
index 0000000000..c1a8890a8a
--- /dev/null
+++ b/activerecord/test/models/tag.rb
@@ -0,0 +1,16 @@
+# 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