From 1b33682f2d786702889f127b14f05df0321fc91b Mon Sep 17 00:00:00 2001 From: Nick LaMuro Date: Tue, 29 Sep 2020 17:03:01 -0500 Subject: [PATCH] [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