1

私は解決策を探していましたが、私が見つけたものは私の問題を解決しませんでした. #235 Omniauth Part 1チュートリアルに従って、Web に Facebook 認証を追加します。アクセスするlocalhost:3000/auth/facebookとNoMethodErrorが発生しますundefined method 'ssl?' for <Rack::Request:0x7fdacdb89bb0>

このGitHubの問題は、問題は環境にあると述べていますが、解決方法がわかりません。

Gemfile:

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+ バージョンにはメソッドssl?が定義されていますが、レール 3.0.19 のために 1.2.7 でスタックしています。

ssl?アプリ内でメソッドを定義することで解決できました。フォルダにファイルを追加しましrack_patch.rbconfig/initializers。ファイルの内容は次のとおりです。

require 'rack'

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

エラーが発生しなくなり、Facebook からログインできるようになりました。Googleで詳細な回答が見つからなかったので、これが誰かの役に立てば幸いです。

于 2013-02-14T05:24:44.343 に答える