From 03dbd8673a4a183d946673e0b64e62d9e622161a Mon Sep 17 00:00:00 2001 From: Nick LaMuro Date: Tue, 29 Sep 2020 17:03:01 -0500 Subject: [PATCH 1/2] [rails6] Update ActionView::Template::Handlers::RJS.call In Rails6, there is a deprecation warning with `.call` when working with template handlers: DEPRECATION WARNING: Single arity template handlers are deprecated. Template handlers must now accept two parameters, the view object and the source for the view object. Change: >> #.call(template) To: >> #.call(template, source) This borrows from PR 138 in Hamlit that did the same thing: - https://github.com/k0kubun/hamlit - https://github.com/k0kubun/hamlit/blob/master/CHANGELOG.md#293---2019-04-09 --- lib/action_view/template/handlers/rjs.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/action_view/template/handlers/rjs.rb b/lib/action_view/template/handlers/rjs.rb index 6107102..e53eb47 100644 --- a/lib/action_view/template/handlers/rjs.rb +++ b/lib/action_view/template/handlers/rjs.rb @@ -5,8 +5,9 @@ class RJS class_attribute :default_format self.default_format = Mime[:js] - def call(template) - "update_page do |page|;#{template.source}\nend" + def call(template, source=nil) + source ||= template.source + "update_page do |page|;#{source}\nend" end end end From 417da52ad67928a9be61b16073cc663984c6f225 Mon Sep 17 00:00:00 2001 From: Nick LaMuro Date: Tue, 29 Sep 2020 17:27:03 -0500 Subject: [PATCH 2/2] [rails6] replace alias_method_chain While using the `Module.prepend` approach is probably the correct way to do this, the way that this class is defined is pretty gross, so I would rather avoid trying to deal with that and simply replicate the functionality `alias_method_chain` provided by doing two `alias_method` calls. This is a Gem the probably should just die anyway, so I am not terribly bothered by the hack... --- lib/jquery-rjs/rendering.rb | 7 ++++--- lib/jquery-rjs/selector_assertions.rb | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/jquery-rjs/rendering.rb b/lib/jquery-rjs/rendering.rb index e2350d8..0b42a74 100644 --- a/lib/jquery-rjs/rendering.rb +++ b/lib/jquery-rjs/rendering.rb @@ -8,6 +8,7 @@ def render_with_update(options = {}, locals = {}, &block) render_without_update(options, locals, &block) end end - - alias_method_chain :render, :update -end \ No newline at end of file + + alias_method :render_without_update, :render + alias_method :render, :render_with_update +end diff --git a/lib/jquery-rjs/selector_assertions.rb b/lib/jquery-rjs/selector_assertions.rb index babf4ec..4d78c88 100644 --- a/lib/jquery-rjs/selector_assertions.rb +++ b/lib/jquery-rjs/selector_assertions.rb @@ -219,7 +219,8 @@ def response_from_page_with_rjs response_from_page_without_rjs end end - alias_method_chain :response_from_page, :rjs + alias_method :response_from_page_without_rjs, :response_from_page + alias_method :response_from_page, :response_from_page_with_rjs # Unescapes a RJS string. def unescape_rjs(rjs_string)