I'm wondering if this is specific to Win7. I have an app. I hit an exception while running it. I then change the line of code that was broken and send the Post again (by interacting with the page, since it's a PRG, not hitting F5). However, I still get the same exception. I've tested this by changing some logging messages and get the same result: the new code is not seen.
The code I'm altering is in my lib folder. That definitely seems to be the issue. But I have this in my application.rb: config.autoload_paths << 'lib'
and config.autoload_paths += Dir["#{config.root}/lib/**/"]
-- that looks like it covers it (possibly twice).
I've tried the solutions in these posts:
Rails3 not reloading code in lib while in development mode
Rails 3 - how to refresh updated code
Neither one worked. The only differences that I can see is that I'm running a debugger and I'm on Win7. If I restart Mongrel the new code is used.
What can I do to get the Rails runtime to use the new code without restarting?
For reference, this is what I see when I start the debugger:
Fast Debugger (ruby-debug-ide 0.4.17.beta8, ruby-debug-base 0.11.30.pre3) listens on 127.0.0.1:19223
=> Booting Mongrel
=> Rails 3.1.1 application starting in development on http://127.0.0.1:3001
=> Call with -d to detach
=> Ctrl-C to shutdown server
TO the best of my knowledge, code in /lib
is by default loaded once and only once, when the server starts. Therefore, if you change code in your /lib
folder, you'll need to restart the server to see the changes.
If you want to have code loaded on each request, use require_dependency
http://apidock.com/rails/v3.1.0/ActiveSupport/Dependencies/Loadable/require_dependency
Naturally, you'll only want to use require_dependency
in development mode, and a normal require
in test and production modes.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.