1

我一直在寻找解决方案,但我发现的那些并没有解决我的问题。我正在关注#235 Omniauth 第 1 部分教程,以在我的网络中添加 Facebook 身份验证。当我访问时,localhost:3000/auth/facebook我得到一个 NoMethodErrorundefined method 'ssl?' for <Rack::Request:0x7fdacdb89bb0>

这个GitHub问题说问题出在环境中,但我不知道如何解决。

宝石文件:

source 'http://rubygems.org'

gem 'rails', '3.0.1'
gem 'sqlite3-ruby', :require => 'sqlite3'

# User management plugin
gem 'devise'

# Photo attachment management plugin
# gem 'paperclip'

# Form simplifier
gem 'simple_form'
gem 'country-select'

# Add jquery
gem 'jquery-rails'

# Add gravatar images
gem 'gravatar_image_tag'

# VCard generation
gem 'vpim'

# Use unicorn as the web server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug'

# Bundle the extra gems:
# gem 'bj'
# gem 'nokogiri'
# gem 'sqlite3-ruby', :require => 'sqlite3'
# gem 'aws-s3', :require => 'aws/s3'

# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
# group :development, :test do
#   gem 'webrat'
# end
gem 'oauth2'
gem 'omniauth'
gem 'omniauth-facebook'
gem 'rack-ssl'

Gemfile.lock:

GEM
  remote: http://rubygems.org/
  specs:
    abstract (1.0.0)
    actionmailer (3.0.1)
      actionpack (= 3.0.1)
      mail (~> 2.2.5)
    actionpack (3.0.1)
      activemodel (= 3.0.1)
      activesupport (= 3.0.1)
      builder (~> 2.1.2)
      erubis (~> 2.6.6)
      i18n (~> 0.4.1)
      rack (~> 1.2.1)
      rack-mount (~> 0.6.12)
      rack-test (~> 0.5.4)
      tzinfo (~> 0.3.23)
    activemodel (3.0.1)
      activesupport (= 3.0.1)
      builder (~> 2.1.2)
      i18n (~> 0.4.1)
    activerecord (3.0.1)
      activemodel (= 3.0.1)
      activesupport (= 3.0.1)
      arel (~> 1.0.0)
      tzinfo (~> 0.3.23)
    activeresource (3.0.1)
      activemodel (= 3.0.1)
      activesupport (= 3.0.1)
    activesupport (3.0.1)
    arel (1.0.1)
      activesupport (~> 3.0.0)
    bcrypt-ruby (2.1.4)
    bcrypt-ruby (2.1.4-x86-mingw32)
    builder (2.1.2)
    country-select (1.0.5)
    devise (1.1.3)
      bcrypt-ruby (~> 2.1.2)
      warden (~> 0.10.7)
    erubis (2.6.6)
      abstract (>= 1.0.0)
    faraday (0.8.4)
      multipart-post (~> 1.1)
    gravatar_image_tag (1.0.0)
    hashie (1.2.0)
    httpauth (0.2.0)
    i18n (0.4.2)
    jquery-rails (0.2.6)
      rails (~> 3.0)
      thor (~> 0.14.4)
    jwt (0.1.5)
      multi_json (>= 1.0)
    mail (2.2.10)
      activesupport (>= 2.3.6)
      i18n (~> 0.4.1)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.16)
    multi_json (1.5.0)
    multipart-post (1.1.5)
    oauth2 (0.8.0)
      faraday (~> 0.8)
      httpauth (~> 0.1)
      jwt (~> 0.1.4)
      multi_json (~> 1.0)
      rack (~> 1.2)
    omniauth (1.1.2)
      hashie (~> 1.2)
      rack
    omniauth-facebook (1.4.1)
      omniauth-oauth2 (~> 1.1.0)
    omniauth-oauth2 (1.1.1)
      oauth2 (~> 0.8.0)
      omniauth (~> 1.0)
    polyglot (0.3.1)
    rack (1.2.8)
    rack-mount (0.6.13)
      rack (>= 1.0.0)
    rack-ssl (1.3.3)
      rack
    rack-test (0.5.6)
      rack (>= 1.0)
    rails (3.0.1)
      actionmailer (= 3.0.1)
      actionpack (= 3.0.1)
      activerecord (= 3.0.1)
      activeresource (= 3.0.1)
      activesupport (= 3.0.1)
      bundler (>= 1.0.0)
      railties (= 3.0.1)
    railties (3.0.1)
      actionpack (= 3.0.1)
      activesupport (= 3.0.1)
      rake (>= 0.8.4)
      thor (~> 0.14.0)
    rake (0.8.7)
    simple_form (1.5.2)
      actionpack (~> 3.0)
      activemodel (~> 3.0)
    sqlite3-ruby (1.3.1)
    sqlite3-ruby (1.3.1-x86-mingw32)
    thor (0.14.6)
    treetop (1.4.9)
      polyglot (>= 0.3.1)
    tzinfo (0.3.23)
    vpim (0.695)
    warden (0.10.7)
      rack (>= 1.0.0)

PLATFORMS
  ruby
  x86-mingw32

DEPENDENCIES
  country-select
  devise
  gravatar_image_tag
  jquery-rails
  oauth2
  omniauth
  omniauth-facebook
  rack-ssl
  rails (= 3.0.1)
  simple_form
  sqlite3-ruby
  vpim
4

1 回答 1

2

我刚才也有同样的问题。1.4+ 版本的 rackssl?定义了方法,但由于 rails 3.0.19,我被困在 1.2.7 上。

我能够通过ssl?在我的应用程序中定义方法来解决它。我rack_patch.rbconfig/initializers文件夹中添加了一个文件。该文件的内容如下:

require 'rack'

Rack::Request.class_eval do
    def ssl?
     scheme == 'https'
    end
end

I am not getting the error anymore and able to login through facebook. Hopefully this helps someone as I could not find a detailed answer through google.

于 2013-02-14T05:24:44.343 回答