传递给 #or 的关系必须在结构上与 Rails 5.1 兼容 5.2



我的应用程序在 Rails 5.1 更新到 5.2 后坏了

错误是:Relation passed to #or must be structurally compatible, Incompatible values: [:create_with]):,我无法理解出了什么问题。

问题来自这个范围

scope :publication, -> do
where.not(type: 'Content::Teaser').
where.not(home_position: nil).
or(
Content::Teaser.where(
id: Content::Teaser.select(:id).joins(:content).where(content: Content.publication)
)
)
end

为什么会出现此错误?

# scope should only really be used for one-liners as its just syntactic sugar 
# and hurts the readability of your code
def self.publication
where.not(type: 'Content::Teaser').
where.not(home_position: nil).or(
# provided that Content.publication is a scope
Content::Teaser.joins(:content).where(Content.publication) 
)
)
end

最新更新