From 9b2fb0f15d016e5bd8d21dae5b902a85d5d82b67 Mon Sep 17 00:00:00 2001 From: Osama Sayegh Date: Thu, 15 Apr 2021 06:27:35 +0300 Subject: [PATCH] DEV: Compatibility with Discourse on Rails 6.1 (#14) Related to https://github.com/discourse/discourse/pull/12688. Rails 6.1 changes the initializer of `ActionView::Base` to require 3 arguments. Instead of creating the instance ourselves, we can use the [`ActionView::Base.with_view_paths`](https://github.com/rails/rails/blob/c5929d5eb55b749bc124b3ccc2d79323d015701f/actionview/lib/action_view/base.rb#L229-L231) method that gives us an instance with whatever view paths we need. The `with_view_paths` method is available in Rails 6.0.3.5 (Discourse's current Rails version), so this change is backward compatible. --- app/jobs/yearly_review.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/jobs/yearly_review.rb b/app/jobs/yearly_review.rb index adcb837..a3a5d5d 100644 --- a/app/jobs/yearly_review.rb +++ b/app/jobs/yearly_review.rb @@ -22,7 +22,7 @@ def execute(args) return if Topic.where(user: Discourse.system_user, title: title).exists? end - view = ActionView::Base.new(ActionView::LookupContext.new(ActionController::Base.view_paths), {}) + view = ActionView::Base.with_view_paths(ActionController::Base.view_paths) view.class_eval do include YearlyReviewHelper def compiled_method_container