Skip to content

Commit

Permalink
Use eager_load instead of cache_classes
Browse files Browse the repository at this point in the history
In `formtastic/helpers/input_helper.rb`, `eager_load` is used to
determine if `const_defined?` should be used.
With `cache_classes = true`, classes are still not loaded at startup, so
some inputs may not be loaded.
  • Loading branch information
gdott9 committed Nov 21, 2014
1 parent f0bb3e3 commit 5a59370
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/formtastic/namespaced_class_finder.rb
Expand Up @@ -28,6 +28,10 @@ class NamespacedClassFinder
class NotFoundError < NameError
end

def self.use_const_defined?
defined?(Rails) && ::Rails.application && ::Rails.application.config.eager_load
end

# @param namespaces [Array<Module>]
def initialize(namespaces)
@namespaces = namespaces.flatten
Expand Down Expand Up @@ -62,7 +66,7 @@ def class_name(as)

private

if defined?(Rails) && ::Rails.application && ::Rails.application.config.cache_classes
if use_const_defined?
def finder(class_name) # @private
find_with_const_defined(class_name)
end
Expand Down

0 comments on commit 5a59370

Please sign in to comment.