Skip to content

Commit

Permalink
need to explicitly require a resolver rails 6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
eudoxa committed May 11, 2023
1 parent 8f02c65 commit 77ba5f3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
26 changes: 10 additions & 16 deletions lib/chanko/config.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
module Chanko
class NoCacheFileSystemResolver < ActionView::FileSystemResolver
def query(path, details, formats, locals, cache:)
super(path, details, formats, locals, cache: false)
end
end
require 'chanko/resolver/no_cache_file_system_resolver'

module Chanko
module Config
class << self
attr_accessor(
Expand All @@ -27,16 +23,7 @@ def reset
self.propagated_errors = []
self.proxy_method_name = :unit
self.raise_error = Rails.env.development?

if Rails::VERSION::MAJOR >= 7
self.resolver = ActionView::FileSystemResolver
else
if Rails.env.development?
self.resolver = Chanko::NoCacheFileSystemResolver
else
self.resolver = ActionView::OptimizedFileSystemResolver
end
end
self.resolver = file_resolver_for_using_version_of_rails
self.units_directory_path = "app/units"
end

Expand All @@ -47,6 +34,13 @@ def units_directory_path=(path)
def units_directory_path
@resolved_units_directory_path ||= Rails.root.join(@units_directory_path).to_s
end

def file_resolver_for_using_version_of_rails
return ActionView::FileSystemResolver if Rails::VERSION::MAJOR >= 7
return Chanko::Resolver::NoCacheFileSystemResolver if Rails.env.development?
return ActionView::OptimizedFileSystemResolver
end
private :file_resolver_for_using_version_of_rails
end

reset
Expand Down
12 changes: 7 additions & 5 deletions lib/chanko/resolver/no_cache_file_system_resolver.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
unless defined?(ActionView::FileSystemResolver)
require 'action_view/template/resolver'
end

module Chanko
module Resolver
if defined?(ActionView::OptimizedFileSystemResolver)
class NoCacheFileSystemResolver < ActionView::OptimizedFileSystemResolver
def query(path, details, formats, locals, cache:)
super(path, details, formats, locals, cache: false)
end
class NoCacheFileSystemResolver < ActionView::FileSystemResolver
def query(path, details, formats, locals, cache:)
super(path, details, formats, locals, cache: false)
end
end
end
Expand Down

0 comments on commit 77ba5f3

Please sign in to comment.