0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

omniauth-facebookでのログインで、NoMethodError(`ssl?`メソッド)が出た時の解決法

Posted at

omniauth-facebookを利用したログインで、

A NoMethodError occurred in #:

 undefined method `ssl?' for #<Rack::Request:0x00000016927848>
 omniauth (1.1.2) lib/omniauth/strategy.rb:408:in `full_host'

というエラーが出るようになってしまった。その解決法のメモ。

環境

rails v3.0.20

$ bundle list
Gems included by the bundle:
...
  * oauth2 (0.8.0)
  * omniauth (1.1.2)
  * omniauth-facebook (1.4.1)
  * omniauth-oauth2 (1.1.1)
…
  * rack (1.2.8)
  * rack-mount (0.6.14)
  * rack-test (0.5.7)
  * rails (3.0.20)
...

原因

どうやらインストールされているrackのバージョン(1.2.8)が古いため、ssl?メソッドを持っていないらしい。(v1.4以降から定義されている)

解決法

config/initializersディレクトリ以下に新しいファイルを作成し、ssl?メソッドを定義する。

config/initializers/rack_path.rb
require 'rack'

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

これで一応解決した。

まあrackの最新版を使えって話ですかね。。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?