【问题标题】:Server won't start on using authlogic-oauth2服务器无法使用 authlogic-oauth2 启动
【发布时间】:2011-05-28 01:44:38
【问题描述】:

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

/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。在我添加之前,服务器似乎也开始正常了

gem "authlogic-oauth2"

到 Gemfile。

【问题讨论】:

  • rails 配置文件是什么意思?在我将行 gem "authlogic-oauth2" 添加到 Gemfile 之前,服务器似乎开始正常。告诉我你需要看什么文件

标签: ruby-on-rails ruby ruby-on-rails-plugins webrick oauth-2.0


【解决方案1】:

authlogic-oauth2 不再由 Andrew 负责。对于更新的 gem,请尝试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

希望这可以为您解决问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-28
    • 1970-01-01
    • 2019-07-20
    • 2011-08-05
    • 2018-10-30
    • 2021-07-21
    • 2016-03-22
    • 1970-01-01
    相关资源
    最近更新 更多