I have two scopes in a model. Both utilize joins
. It appears that joins
is incompatible with the Rails 5 or query.
Example:
class Blog < ApplicationRecord
has_many :comments
scope :with_comment_likes, -> {joins(:comments).merge(Comment.some_scope_on_comment)}
scope :some_other_comment_merge_scope, -> {joins(:comments).merge(Comment.other_scope)}
scope :aggregate_or_scope, -> {with_comment_likes.or(some_other_comment_merge_scope)}
end
Blog.aggregate_or_scope
Returned error:
ArgumentError: Relation passed to #or must be structurally compatible.
Incompatible values: [:joins]
Any suggestions for how to get around this? I'm stumped. I did see this question, but I was having trouble applying it.