tags:

views:

774

answers:

3

I am using

# my_app.rb
load 'index.rb'

and start the sever like this

ruby my_app.rb

but it never reload any changes I made in index page.

Did I miss anything here?

thanks

+1  A: 

(Briefly, without knowing more details) this might help:

"In no circumstance will any local variables in the loaded file be propagated to the loading environment."

From 'load' in RubyDocs.

Dave Everitt
+13  A: 

See the Sinatra FAQ,

"What happened to reloading in Sinatra 0.9.2?"

Source file reloading was removed in the 0.9.2 due to excess complexity. The shotgun program can be used to achieve the same in most situations. Install shotgun via gem and run your app as follows:

$ sudo gem install shotgun
$ shotgun myapp.rb

Passenger users can use the tmp/always_restart.txt file.

Another option may be the Rack::Reloader middleware, which reloads source files before each request.

dbr
A: 

gem install sinatra-reloader

require 'sinatra'
require 'sinatra/reloader'

Note: it will reload only sinatra handlers (and, maybe some sinatra server configuration commands), but not custom files, which you have to reload manually.

Nakilon