ruby - sinatra-authentication gem 不是在寻找正确的 View 吗?

标签 ruby authentication view sinatra mongoid

我正在尝试用 sinatra 和 mongoid 为自己编写一个小型博客引擎,并尝试使用 sinatra-authentication gem进行登录/退出。

我已经让 sinatra、mongoid 和 haml 都正常工作,但是当我访问任何 sinatra 身份验证页面时,nginx 会抛出一个内部服务器错误。

这是我遇到的错误

Errno::ENOENT - No such file or directory -     /opt/nginx/html/raptor.patrickarlt.com/views/layout.haml:

您可以在此处查看我的所有文件,包括我的 nginx 错误日志中的更多文件 https://gist.github.com/854156

获取 '/' 确认 Sinatra 正在工作
得到 '/haml' works 确认 haml 正在工作
get '/private' 重定向到 '/login' 确认 sinatra-authentication 正在工作
得到 '/login' 内部服务器错误

ruby 1.9.2
Nginx 0.8.54
乘客 3.0.2

最佳答案

sinatra-authentication 假定您正在使用布局,除非当前请求是 XMLHttpRequest(参见 the code)。您有两个选择:

  1. views/layout.haml 中为您的应用程序创建布局,如以下几段所述 http://sinatra-book.gittr.com/#templates
  2. 重写 sinatra-authentication 的 use_layout? 方法:

    module Sinatra
      module Helpers
        def use_layout?
          false
        end
      end
    end
    

关于ruby - sinatra-authentication gem 不是在寻找正确的 View 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5189561/

相关文章:

ruby-on-rails - 在Rails应用的 View 或部分 View 中使用binding.pry

ruby - 有没有其他方法可以为 Ruby 挽救 LoadError?

php - 哈希密码 php

cakephp-1.3 - cakePHP Auth - 允许/拒绝, isAuthorized 实际需要什么?

Java EE 身份验证错误处理

ios - 返回 IOS 模拟器时查看崩溃情况

ruby - ruby 中的子类可以访问实例变量吗?

ruby-on-rails - Amazon SES 中的拉丁字符

Ruby 如何反转显示顺序

iphone - UITabBarController - 如何为简单的开关设置动画?