我将rails 5.1.4 app更新为5.2.0.我的一个模型中有以下范围:
scope :by_category, lambda { |category_slug|
category_ids = Category.find_by(slug: category_slug)&.subtree_ids
where(category_id: category_ids)
}
Run Code Online (Sandbox Code Playgroud)
由于该范围,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()
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?