服务器不会开始使用 authlogic-oauth2 [英] Server won't start on using authlogic-oauth2

查看:64
本文介绍了服务器不会开始使用 authlogic-oauth2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 gemfile 中包含了 oauth2 和 authlogic-oauth2,因为我想使用它们并且正在尝试启动服务器.它没有启动并给我错误:

I have included oauth2 and authlogic-oauth2 in the gemfile as I want to use them and am trying to start the server. It doesn't start and gives me the error:

/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails.rb:44:in `configuration': undefined method `config' for nil:NilClass (NoMethodError)
        from /Library/Ruby/Gems/1.8/gems/authlogic_oauth2-1.1.2/lib/authlogic_oauth2.rb:14
        from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:64:in `require'
        from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:64:in `require'
        from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:62:in `each'
        from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:62:in `require'
        from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:51:in `each'
        from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:51:in `require'
        from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler.rb:112:in `require'
        from /Users/arkidmitra/Documents/qorm_bzar/buyzaar/config/application.rb:7
        from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/commands.rb:28:in `require'
        from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/commands.rb:28
        from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/commands.rb:27:in `tap'
        from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/commands.rb:27
        from script/rails:6:in `require'
        from script/rails:6

我使用的是 Rails 3.0.3 和 Ruby 1.8.7.此外,服务器似乎开始正常,直到我添加

I am using Rails 3.0.3 and Ruby 1.8.7. Also the sever seems to be starting fine till I add

gem "authlogic-oauth2"

到 Gemfile.

推荐答案

安德鲁不再负责 authlogic-oauth2.对于更新的 gem,请尝试 https://github.com/robdimarco/authlogic_oauth2

The authlogic-oauth2 is no more taken care by Andrew. For the updated gem try https://github.com/robdimarco/authlogic_oauth2

Here the authlogic_oauth2.rb had been changed.
require File.dirname(__FILE__) + "/authlogic_oauth2/version"
require File.dirname(__FILE__) + "/authlogic_oauth2/oauth2_process"
require File.dirname(__FILE__) + "/authlogic_oauth2/acts_as_authentic"
require File.dirname(__FILE__) + "/authlogic_oauth2/session"
require File.dirname(__FILE__) + "/authlogic_oauth2/helper"
require File.dirname(__FILE__) + "/oauth2_callback_filter"

ActiveRecord::Base.send(:include, AuthlogicOauth2::ActsAsAuthentic)
Authlogic::Session::Base.send(:include, AuthlogicOauth2::Session)
ActionController::Base.helper AuthlogicOauth2::Helper

# Throw callback rack app into the middleware stack
if defined?(ActionController::Metal)
  module AuthlogicOAuth2
    class Railtie < Rails::Railtie
      initializer :load_oauth2_callback_filter do |app|
        app.config.middleware.use(Oauth2CallbackFilter) # Rails >= 3.0
      end
    end
  end
else
  ActionController::Dispatcher.middleware.use(Oauth2CallbackFilter) # Rails < 3.0
end

希望这能为您解决问题.

Hope this solves the problem for you.

这篇关于服务器不会开始使用 authlogic-oauth2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆