From c0ecdb9e3aafcf609781c1bfd80b0728f32050f3 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Mon, 23 Dec 2019 13:57:33 +0100 Subject: [PATCH] Fix deprecated #includes in join without reference DEPRECATION WARNING: It looks like you are eager loading table(s) (one of: variant_overrides, enterprises, enterprise_roles) that are referenced in a string SQL snippet. For example: Post.includes(:comments).where("comments.title = 'foo'") Currently, Active Record recognizes the table in the string, and knows to JOIN the comments table to the query, rather than loading comments in a separate query. However, doing this without writing a full-blown SQL parser is inherently flawed. Since we don't want to write an SQL parser, we are removing this functionality. From now on, you must explicitly tell Active Record when you are referencing a table from a string: Post.includes(:comments).where("comments.title = 'foo'").references(:comments) If you don't rely on implicit join references you can disable the feature entirely by setting `config.active_record.disable_implicit_join_references = true`. (called from collection at /home/user/Github/openfoodnetwork/app/controllers/admin/variant_overrides_controller.rb:77) --- app/controllers/admin/variant_overrides_controller.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/variant_overrides_controller.rb b/app/controllers/admin/variant_overrides_controller.rb index e12b43825b..331bfe6fce 100644 --- a/app/controllers/admin/variant_overrides_controller.rb +++ b/app/controllers/admin/variant_overrides_controller.rb @@ -73,7 +73,10 @@ module Admin end def collection - @variant_overrides = VariantOverride.includes(:variant).for_hubs(params[:hub_id] || @hubs) + @variant_overrides = VariantOverride. + includes(:variant). + for_hubs(params[:hub_id] || @hubs). + references(:variant) @variant_overrides.select { |vo| vo.variant.present? } end