From 34cee13f1a84b145837b31b1b1f64c73d9f281a8 Mon Sep 17 00:00:00 2001 From: schneems Date: Sat, 11 Jun 2022 17:41:28 -0500 Subject: [PATCH] Patch for Rails 7 Documented in https://github.com/zombocom/maildown/issues/59. This class was removed from Rails 7. This causes an error on this line when trying to alias a method that does not exist https://github.com/zombocom/maildown/blob/cbf5b51e0867eab1ec945d38b5335f42139b0322/lib/maildown/ext/action_view.rb#L7. The solution presented was to re-add the method. However simply doing this with a `defined?(OptimizedFileSystemResolver)` causes a load via zeitwork and also results in a crash. The presence of this code appears to do nothing in Rails 7. It's basically a no-op that allows us to boot without erroring. --- lib/maildown/ext/action_view.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/maildown/ext/action_view.rb b/lib/maildown/ext/action_view.rb index 9d680ee..375e2ab 100644 --- a/lib/maildown/ext/action_view.rb +++ b/lib/maildown/ext/action_view.rb @@ -1,5 +1,20 @@ # frozen_string_literal: true +if !defined?(ActionView::OptimizedFileSystemResolver) + module ActionView + # https://github.com/codetriage/maildown/issues/59 + # + # extract_handler_and_format_and_variant was removed in https://github.com/rails/rails/commit/2be8d3ebf85e26e936a7717b968737ee333d95bd + # OptimizedFileSystemResolver was removed in https://github.com/rails/rails/commit/faac734387124c6d780dbfcfdab721b2f26ce865 + class OptimizedFileSystemResolver < FileSystemResolver + def extract_handler_and_format_and_variant(template) + details = @path_parser.parse(template) + [details.handler, details.format, details.variant] + end + end + end +end + # This monkeypatch allows the use of `.md.erb` file extensions # in addition to `.md+erb` and `.md` module ActionView