5

After many googling I've tried adding both of these to my config and yet reloading doesn't happen:

config.autoload_paths += %W(#{config.root}/lib)
config.autoload_paths += Dir["#{config.root}/lib/**/"]

I make changes to files under /lib but refreshing in Pow doesn't reload the changes

What am I missing?

Bernhard Barker
  • 54,589
  • 14
  • 104
  • 138
user1749366
  • 53
  • 1
  • 3

1 Answers1

7

You'll want to restart pow after changing files in /lib because Rails initializes objects here as it starts up and doesn't load them again after having started up (so changes while the server is up won't make a difference). To overcome this, you have a few options:

  1. You may want to look at using require_dependency.

  2. You can restart Pow by touching the restart.txt file: touch ~/.pow/restart.txt

  3. For a more convenient solution if you're changing your lib folder a lot, add anvil to handle your restarts easily.

  4. If you don't want to do this, just add your classes to the /app path into a new folder.

MicTech
  • 42,457
  • 14
  • 62
  • 79
Simpleton
  • 6,285
  • 11
  • 53
  • 87
  • But isn't that what autoload_paths is for? to tell rails what more to reload? – user1749366 Oct 16 '12 at 09:05
  • That's to autoload not auto-reload. If you really want to, there's some hacks here: http://stackoverflow.com/questions/3282655/ruby-on-rails-3-reload-lib-directory-for-each-request – Simpleton Oct 16 '12 at 09:18