0

I have a custom helpers path lib/helpers, which i autoload by adding following in application.rb:

config.autoload_paths += %W(classes helpers).map{|dir| "#{Rails.root}/lib/#{dir}"}

One of the helpers, VideoHelper, utilizes FileHelper in one of it's methods:

class VideoHelper

 def my_method
  FileHelper::my_method
 end

end

While testing VideoHelper's my_method with rspec, all calls to FileHelper::my_method fail with:

NameError:
   uninitialized constant VideoHelper::FileHelper

Tests succeed if i add call to FileHelper before VideoHelper class declaration:

FileHelper
class VideoHelper

 def my_method
  FileHelper::my_method
 end

end

Do i have to require FileHelper in VideoHelper even when it's declared in autoload_paths?

Pavel K.
  • 6,697
  • 8
  • 49
  • 80

1 Answers1

0

Found a must-read on the topic:

http://urbanautomaton.com/blog/2013/08/27/rails-autoloading-hell/

Pavel K.
  • 6,697
  • 8
  • 49
  • 80