2
votes

I have a simple class in a file in lib/simple.rb.

In the console (rails c) I have a couple of problems:

  1. Rails seems unable to load the file even though application.rb contains config.autoload_paths += %W(#{config.root}/lib/**). How to make Rails 3.2 behave like Rails 2.x used to (I never had problems in Rails 2.x with this autoload stuff - Rails 3 seems like a step back :( )

  2. If I make a change to simple.rb and call reload! in console, it does not reload the file. I have to do load "#{Rails.root}/lib/simple.rb to make it reload. Is there a way to make reload! work like it used to in Rails 2.x? i.e. just make it reload all files without having to use load at all?

1

1 Answers

2
votes

It should be the folder containing the class you want to load. Therefore, should be

config.autoload_paths += %W(#{config.root}/lib)

If your app is threadsafe!, change config.autoload_paths to config.eager_load_paths. Once you do this, reload! should behave as you've described.