Normally I put files in the rails lib folder and they seem to be loaded automatically.
I recently tried putting this file : https://gist.github.com/85632 in my lib folder.
From one of my models when I try to do:
ftp = Net::FTPS::Implicit::new(
I get:
NameError: uninitialized constant Net::FTPS
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:440:in `load_missing_constant'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in `const_missing'
from /Users/jnylund/Projects/aras/app/models/notifier.rb:372:in `send_ftp_file'
I got it to work by adding:
require ‘ftps_implicit’
to the top of my model file.
Why in this case did I need to do this? Is this the right way of doing things?
thanks
Joel
Rails 2 will load up files by convention. So when you request:
… it will look for the file:
… to define that class.
I don’t think Rails 2 actually loads everything up in the
libfolder – it only looks in there for a file when something is requested.