もともとSinatraではRack::Reloaderが上手く機能しないのでshotgunを使おうという流れだったのですが、諸般の事情でshotgunを使えない状況になったため、本腰を入れてRack::Reloaderを使えるようにする方法を調べました。

結論として、以下のようにすれば使えました。

config.ru

   1  configure :development do
   2    class Sinatra::Reloader < Rack::Reloader
   3      def safe_load(file, mtime, stderr = $stderr)
   4        ::Sinatra::Application.reset!
   5        use_in_file_templates! file
   6        stderr.puts "#{self.class}: reseting routes"
   7        super
   8      end
   9    end
  10    use Sinatra::Reloader
  11  end

reset!を呼び出した後use_in_file_templates!を呼ぶ事で、in-fileテンプレートをもう一度読み込んでいます。

posted by Png genki on Mon 12 Oct 2009 at 02:30
Contents
Sinatraでshotgunの代わりにRack::Reloaderを使う方法
Comments
瀧内元気: MacOS版は以下にあります * [genki/ViMouse](https://githu... '23-1
KingofSmack: Here also good reads for this mobile applicatio... '14-5
Spencer: You don't have to re-compile it, this version w... '14-4
staiano: Any chance we can get a recompile for 10.9? '14-1
dsjf: https://gist.github.com/6bf1bf2c3cbb5eb6e7a7 これ... '13-1
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ