【问题标题】:Devise with Omniauth for facebook authentication使用 Omniauth 设计用于 facebook 身份验证
【发布时间】:2011-08-28 06:31:57
【问题描述】:

我正在运行 ruby​​ 1.9.2p18、Devise (1.3.4)、Rails (3.0.4) 和 Omniauth (0.2.6)。

目前我的网页正在使用 Devise 进行身份验证,它工作正常。

我正在尝试向其添加 facebook 身份验证。我按照https://github.com/plataformatec/devise/wiki/OmniAuth%3a-Overview 的指示进行操作。

当我做 localhost:3000 我得到

LoadError (no such file to load -- omniauth/core):
  app/models/user.rb:3:in `<class:User>'
  app/models/user.rb:1:in `<top (required)>'
  config/routes.rb:6:in `block in <top (required)>'
  config/routes.rb:1:in `<top (required)>'

如果再次刷新页面,有时我会得到

ActionController::RoutingError (No route matches "/")

我查看并在 .rvm/gems/ruby-1.9.2-p180/gems/omniauth-0.2.6 下有目录 oa-core/ 但没有 core/ 。

非常感谢您的帮助,我不知道如何调试这个!

【问题讨论】:

    标签: ruby-on-rails-3 facebook devise omniauth


    【解决方案1】:

    2 个错误是不同的。

    1.错误:

    LoadError (no such file to load -- omniauth/core)
    

    您需要将omniauth 添加到您的Gemfile 并运行“捆绑安装”。如果您对此有疑问,此 Railscast 可能会有所帮助: Railscasts Omniauth 1

    另请参阅 Railscasts 上的 2 个设计视频。

    2。错误:

    ActionController::RoutingError (No route matches "/")
    

    它表示您尚未将应用配置为具有主根目录。主根是匹配“/”的。
    - 首先选择您想作为登陆页面或主页的页面。如果您还没有创建一个,那就去做吧。
    - 接下来,您可以通过“rake routes”从 shell 中找到所有命名路由。
    - 然后打开 config/routes.rb 文件并通过以下方式添加主根目录:

    root :to => 'welcome#index'
    

    用“your_chosen_controllers_name#chosen_method”替换“welcome#index”
    不要添加由 Devise 创建的命名路由,因为它会导致无限循环 (“堆栈级别太深”错误)。

    请注意,如果您之前没有使用过 Rails,Devise wiki 建议不要使用 Devise。在这种情况下,我强烈建议检查 Rails3.1 new has_secure_password?方法。
    高温

    【讨论】:

    • @meena,你得到这个解决方案了吗?我有同样的问题,但无法得到解决方案。如果您有解决方案,请告诉我。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多