ArgumentError: relation passed in # or should be structurally compatible. Incompatible values: [: join]

I have two models in the model. Both use joins . It looks like joins incompatible with a Rails 5 or request.

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 

Error returned:

ArgumentError: relation passed in # or should be structurally compatible. Incompatible values: [: join]

Any suggestions on how to get around this? I'm at a dead end. I saw this question , but I had problems with its application.

+5
source share

Source: https://habr.com/ru/post/1271860/


All Articles