Sinatra:堆栈级别太深

时间:2016-04-11 21:58:23

标签: ruby sinatra

Sinatra:Up and Running (示例4-22)中有一个代码示例。当我尝试运行它时,会得到以下结果:stack level too deep

require 'sinatra/base'

class ApplicationController < Sinatra::Base 
  def self.inherited(sublass)
    super
    use sublass 
  end
  enable :logging 
end

# works with dynamically generated applications, too 
Sinatra.new ApplicationController do
  get '/' do
  "See the <a href='/example'>example</a>."
  end 
end
ApplicationController.run!

确实,这段代码看起来不对,因为新的应用程序扩展了AppController,当AppController use应用程序时它会永远重现。

那怎么做呢?

1 个答案:

答案 0 :(得分:0)

尝试这样的事情:

class SinatraApp < Sinatra::Base
   get '/' do
     "See the <a href='/example'>example</a>."
   end
end

run SinatraApp.new