From 548fd41d7234cacad694a6f8b7b3e10f2e1400ec Mon Sep 17 00:00:00 2001 From: Joe Rafaniello Date: Tue, 7 Jan 2025 17:09:15 -0500 Subject: [PATCH] Resurrect capture of blocks for RJS update in rails 7.1 Bring back the rails 7.0 version of _normalize_args from action_controller/metal/rendering.rb This is a pseudo-revert of the removal in upstream: https://github.com/rails/rails/commit/4bd6251a15f13b645d96862a1ff3cfb5e0ffefdd RJS needs to be removed but this allows it to work with 7.1 until it can be removed. --- lib/jquery-rjs/action_controlller_rendering.rb | 14 ++++++++++++++ lib/jquery-rjs/on_load_action_controller.rb | 1 + 2 files changed, 15 insertions(+) create mode 100644 lib/jquery-rjs/action_controlller_rendering.rb diff --git a/lib/jquery-rjs/action_controlller_rendering.rb b/lib/jquery-rjs/action_controlller_rendering.rb new file mode 100644 index 0000000..fe6c414 --- /dev/null +++ b/lib/jquery-rjs/action_controlller_rendering.rb @@ -0,0 +1,14 @@ +if Rails.version >= "7.1.0.0" + require 'action_controller/metal/rendering' + + module JqueryRjs::ActionControllerRendering + # Normalize arguments by catching blocks and setting them on :update. + def _normalize_args(action = nil, options = {}, &blk) + options = super + options[:update] = blk if block_given? + options + end + end + + ActionController::Rendering.prepend(JqueryRjs::ActionControllerRendering) +end diff --git a/lib/jquery-rjs/on_load_action_controller.rb b/lib/jquery-rjs/on_load_action_controller.rb index 31fa0ec..5592694 100644 --- a/lib/jquery-rjs/on_load_action_controller.rb +++ b/lib/jquery-rjs/on_load_action_controller.rb @@ -1,2 +1,3 @@ +require 'jquery-rjs/action_controlller_rendering' require 'jquery-rjs/selector_assertions' require 'jquery-rjs/renderers'