Reputation: 1933
I following Ryan's subdomain railscast where het creates a Subdomain class used in his routes and places it in the lib directory. Apparantly my rails app isn't looking in the lib dir by default (my app only starts when I move the subdomain.rb file from lib to eg /app/models)
I always thought that the lib dir was included by default in a rails app? How can I best include this directory to make this happen.
Thanks
Upvotes: 1
Views: 556
Reputation: 11055
Rails 3 does not autoload it by default (although Rails 2 does). You have to add it to your autoload_paths in application.rb.
module YourRailsApp
class Application < Rails::Application
config.autoload_paths += %W(#{Rails.root}/lib)
#...
end
end
For more info on the reason behind this see:
https://rails.lighthouseapp.com/projects/8994/tickets/5218-rails-3-rc-does-not-autoload-from-lib
Upvotes: 2