From 4dc2172dd2af205f86c3a6d5d01d68181ffcd2aa Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 26 Dec 2021 14:59:17 +0000 Subject: [PATCH 1/2] Update deprecated #search method name DEPRECATION WARNING: #search is deprecated and will be removed in 2.3, please use #ransack instead (called from search at /home/user/Github/openfoodnetwork/lib/open_food_network/sales_tax_report.rb:40) --- lib/open_food_network/sales_tax_report.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/open_food_network/sales_tax_report.rb b/lib/open_food_network/sales_tax_report.rb index f5f1adab03..3284d5b164 100644 --- a/lib/open_food_network/sales_tax_report.rb +++ b/lib/open_food_network/sales_tax_report.rb @@ -37,7 +37,7 @@ module OpenFoodNetwork def search permissions = ::Permissions::Order.new(user) - permissions.editable_orders.complete.not_state(:canceled).search(params[:q]) + permissions.editable_orders.complete.not_state(:canceled).ransack(params[:q]) end def orders From aaf5d1ba380a6feba47c8d9a906ee90d00539cc8 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 26 Dec 2021 15:10:00 +0000 Subject: [PATCH 2/2] Patch CanCan deprecated keyword arguments Solves an issue with use of deprecated positional args. The version of CanCan which fixes this is not currently compatible with OFN... --- config/initializers/cancancan.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 config/initializers/cancancan.rb diff --git a/config/initializers/cancancan.rb b/config/initializers/cancancan.rb new file mode 100644 index 0000000000..a0dc46e905 --- /dev/null +++ b/config/initializers/cancancan.rb @@ -0,0 +1,12 @@ +module CanCanUnauthorizedMessage + # Fix deprecated syntax calling I18n#translate (using keyword args) without using ** + def unauthorized_message(action, subject) + keys = unauthorized_message_keys(action, subject) + variables = {:action => action.to_s} + variables[:subject] = (subject.class == Class ? subject : subject.class).to_s.underscore.humanize.downcase + message = I18n.translate(nil, **variables.merge(:scope => :unauthorized, :default => keys + [""])) + message.blank? ? nil : message + end +end + +CanCan::Ability.prepend(CanCanUnauthorizedMessage)