开发者

Sinatra Authorization Extension: NameError

Can anyone tell me why I get a NameError - uninitialized constant Sinatra::Default when calling the /admin route?

require "sinatra"
require "sinatra/authorization"

set :authorization_realm, "Protected zone"

helpers do
  def authorize(login, password)
    login == "admin" && password == "secret"
  end
end

get "/" do
  "Welcome to the public zone"
end

get "/admin" do
  login_required
  "Welcome to the protected zone"
end

I'm using Ruby 1.9.2, Sinatra 1.2.6 and the Sinatra Authorization Extension.

UPDATE: OK, I've found the source of the problem at line 25 of the followin开发者_运维百科g file:

sinatra-authorization-1.0.0/lib/sinatra/authorization.rb

This fork of the original project solved the problem by replacing Sinatra::Default.authorization_realm with settings.authorization_realm at line 25. This solves the problem, but I don't understand why. Can anyone explain that to me?


It's solves the problem because Sinatra doesn't have Default class anymore. And if you want to access some settings defined with :set you should use settings. for this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜