From 603a27f495a5cfc70e490ef158169a72d8ca7fbf Mon Sep 17 00:00:00 2001 From: evazion Date: Sat, 28 Apr 2018 13:15:10 -0500 Subject: [PATCH] related tags: fix deprecation warning in order("count(*) DESC"). DEPRECATION WARNING: Dangerous query method (method whose arguments are used as raw SQL) called with non-attribute argument(s): "count(*) DESC". 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(). (called from block in calculate_from_sample at /home/admin/src/danbooru/app/logical/related_tag_calculator.rb:66) --- app/logical/related_tag_calculator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/logical/related_tag_calculator.rb b/app/logical/related_tag_calculator.rb index 2818bb961..11d148a97 100644 --- a/app/logical/related_tag_calculator.rb +++ b/app/logical/related_tag_calculator.rb @@ -63,7 +63,7 @@ class RelatedTagCalculator posts_with_tags = posts_with_tags.joins("JOIN tags ON tags.name = tag").where("tags.category" => category_constraint) end - counts = posts_with_tags.order("count(*) DESC").limit(max_results).group("tag").count + counts = posts_with_tags.order("count_all DESC").limit(max_results).group("tag").count(:all) counts end end