You might have added:
configure :development { use Sinatra::Reloader }
But it's better if the reloader also clears the routes and all
internal stuff of Sinatra too.
------------------ CUT --------------------
# Reload scripts and reset routes on change
class Sinatra::Reloader < Rack::Reloader
def safe_load(file, mtime, stderr = $stderr)
if file == __FILE__
::Sinatra::Application.reset!
stderr.puts "#{self.class}: reseting routes"
end
super
end
end
------------------ CUT --------------------
So now you do:
configure :development { use Sinatra::Reloader }
And have all your routes, external required files reloaded once the
file changed, which is far better than old reload mechanism or shotgun
that reloads on every request.
Have fun!
--
Adam
> You might have added:
> configure :development { use Sinatra::Reloader }
I meant you may simply use:
:development { use Rack::Reloader }
but it doesn't clear the routes of Sintra app if main application file
is reloaded.
So it is better to use `Sinatra::Reloader` from my last mail there
that does reset! for Sinatra::Application too.
If you use my Haml template cache mod this solution does NOT reload
the templates, but I'll post later on some Reloader that watches all
*.haml in views and clears the cache when necessary.
Cheers,
--
Adam
Upgraded to rack 1.0 and it works better now.
Yeah, exactly, using `app_file` is much better. Thanks for a fix.
Regards,
--
Adam | nanoant.com
In this case root.rb is loaded anytime and only if main.rb is
reloaded. Because you use 'load'.
Rack::Reloader (so Sinatra::Reloader) monitors files in
$LOADED_FEATURES for changes, so files that have been 'require'd not
'load'ed.
So instead of using 'load', add your application root to search path
and use 'require':
> require 'handlers/root'
Cheers,
--
Adam