Skip to content

Instantly share code, notes, and snippets.

@skflowne
Created September 11, 2019 14:18
Show Gist options
  • Save skflowne/adcba66362af87f5966c478a4f6d3961 to your computer and use it in GitHub Desktop.
Save skflowne/adcba66362af87f5966c478a4f6d3961 to your computer and use it in GitHub Desktop.
Autoloading modules from lib directory in Rails 3/4
# Let's say we want a Shipping module
config.autoload_paths << Rails.root.join('lib', 'shipping')
# Then it's all about naming conventions
# In lib/shipping/shipping.rb
module Shipping
end
# Then let's say you want a Client class that will be accessible through Shipping::Client
# In lib/shipping/client.rb
class Client
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment