title: DEPRECATION WARNING: Dangerous query method (method whose arguments are used as raw SQL) called with non-attribute argument(s)
body: <p>I updated my rails 5.1.4 app to 5.2.0. I have the following scope in one of my models:</p>
  
  <pre><code>  scope :by_category, lambda { |category_slug|
      category_ids = Category.find_by(slug: category_slug)&amp;.subtree_ids
      where(category_id: category_ids)
    }
  </code></pre>
  
  <p>Rails returns me following error because of that scope:</p>
  
  <pre><code>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()
  </code></pre>
  
  <p>How can I fix that?</p>