From c91d7dc150e9113ae63d7cab99f08d63c1063905 Mon Sep 17 00:00:00 2001 From: Washington Botelho Date: Thu, 1 Mar 2018 13:35:35 -0300 Subject: [PATCH] ref: using inline scope values --- lib/rating/models/rating/extension.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/rating/models/rating/extension.rb b/lib/rating/models/rating/extension.rb index e4365ca..cd601ff 100644 --- a/lib/rating/models/rating/extension.rb +++ b/lib/rating/models/rating/extension.rb @@ -62,13 +62,8 @@ module Rating dependent: :destroy scope :order_by_rating, ->(column = :estimate, direction = :desc, scope: nil) { - scope_values = { - scopeable_id: scope&.id, - scopeable_type: scope&.class&.base_class&.name - } - includes(:rating_records) - .where(Rating.table_name => scope_values) + .where(Rating.table_name => { scopeable_id: scope&.id, scopeable_type: scope&.class&.base_class&.name }) .order("#{Rating.table_name}.#{column} #{direction}") } end