【问题标题】:Rails 3 RESTful Authentication - uninitialized constant ApplicationController::AuthenticatedSystemRails 3 RESTful 身份验证 - 未初始化的常量 ApplicationController::AuthenticatedSystem
【发布时间】:2011-11-24 17:25:41
【问题描述】:

刚刚从https://github.com/Satish/restful-authentication 安装了升级后的 Rails 3 的 restful_authentication 插件。我正在尝试在我的应用程序助手中包含来自插件的代码,如下所示:

class ApplicationController < ActionController::Base
    protect_from_forgery

    include AuthenticatedSystem
end

但是,当我运行服务器并导航到本地主机上的应用程序时,我收到如下错误:

uninitialized constant ApplicationHelper::AuthenticatedSystem

AuthenticatedSystem 是 lib/authenticated_system.rb 中的一个模块,那么为什么包含不起作用?

【问题讨论】:

    标签: ruby-on-rails-3 restful-authentication


    【解决方案1】:

    Rails 3 默认不再加载 /lib 目录中的文件 :(

    将此添加到您的 config/application.rb:

    config.autoload_paths << "#{Rails.root}/lib"
    

    你应该没事的。不要忘记重新启动服务器。

    【讨论】:

    • 谢谢,效果很好!关于默认情况下不再包含它的原因有什么想法吗?
    • 非常感谢我所需要的。
    猜你喜欢
    • 2011-04-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-17
    • 2015-06-23
    相关资源
    最近更新 更多