我将我的 rails 5.1.4 应用程序更新为 5.2.0。我的一个模型中有以下范围:
scope :by_category, lambda { |category_slug|
category_ids = Category.find_by(slug: category_slug)&.subtree_ids
where(category_id: category_ids)
}
由于该范围,Rails 向我返回以下错误:
DEPRECATION WARNING: Dangerous query method (method whose arguments are used as raw SQL) called with non-attribute argument(s): "coalesce(\"categories\".\"ancestry\", '')". Non-attribute arguments will be disallowed in Rails 6.0. This method should not be called with user-provided values, such as request parameters or model attributes. Known-safe values can be passed by wrapping them in Arel.sql()
我该如何解决?