Skip to content

Commit

Permalink
DEV: Compatibility with Discourse on Rails 6.1 (#14)
Browse files Browse the repository at this point in the history
Related to discourse/discourse#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.
  • Loading branch information
OsamaSayegh committed Apr 15, 2021
1 parent 315a0cd commit 9b2fb0f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/jobs/yearly_review.rb
Expand Up @@ -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
Expand Down

0 comments on commit 9b2fb0f

Please sign in to comment.