aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/rating.rb
blob: 2a18ea45aca789043213c5eb3cf3b36b770aa387 (plain) (blame)
1
2
3
4
5
6
7
8
# frozen_string_literal: true

class Rating < ActiveRecord::Base
  belongs_to :comment
  has_many :taggings, as: :taggable
  has_many :taggings_without_tag, -> { left_joins(:tag).where("tags.id": nil) }, as: :taggable, class_name: "Tagging"
  has_many :taggings_with_no_tag, -> { joins("LEFT OUTER JOIN tags ON tags.id = taggings.tag_id").where("tags.id": nil) }, as: :taggable, class_name: "Tagging"
end