Couldn't reload a module when it's changed. Tried :require_dependency, :watchable_dirs, :unloadable

I’m completely messed with module reloading in development mode. I have
to restart app server each time I edit lib/z/nginx.rb which is included
in app/models/user_case.rb

app/models/user_case.rb
require_dependency ‘z/nginx’
class UserCase < ActiveRecord::Base
include Z::Nginx
unloadable

I added to environment.rb
config.watchable_dirs[‘lib’] = [:rb]
config.watchable_dirs[‘lib/z’] = [:rb]
ActiveSupport::Dependencies.explicitly_unloadable_constants +=
%w[Z::Nginx U.Case]

But that doesn’t work for me. When I change a string value, which is
returned by the module method, I get in a view the old value until app
server restarted.

How can I get the new value without restaring app server?

Rails 3.2.3

You need to use autoload_paths:

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


Oscar Del B.
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

Rails 3.x will support the autoload feature…

On Thu, Jun 7, 2012 at 10:29 PM, Oscar Del B.
<[email protected]

wrote:

I’m completely messed with module reloading in development mode. I have
config.watchable_dirs[‘lib’] = [:rb]
Rails 3.2.3
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.


Best Regards.

Richard Ma

My Blog: www.richardma.org

Oscar Del B. wrote in post #1063552:

You need to use autoload_paths:

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

Thank you Oscar! That works for me )