ルーティングの問題でした。
Omniauth は、404 エラー ページを検出することで機能します。
ルート /auth/:provider に一致する場合、要求をキャッチしてプロバイダーに送信します
... しかし、comfortable-mexican-sofa cms (製油所など) にはすべてのルートが含まれているため、リクエストが omniauth で検出できる 404 エラーを返さなかったのはそのためです。
快適なメキシカンソファのケースでは"cms_path"=>"auth/github"
、
NoMethodError in CmsContentController#render_html
undefined method `gsub!' for nil:NilClass
次のようになる正しい omniauth パスの代わりに:
Started GET "/" for 127.0.0.1 at 2011-07-25 22:27:26 +0200
Processing by HomeController#index as HTML
Rendered home/index.html.haml within layouts/application (29.5ms)
Completed 200 OK in 44ms (Views: 42.8ms | ActiveRecord: 0.0ms)
Started GET "/auth/github" for 127.0.0.1 at 2011-07-25 22:27:35 +0200
MONGODB gitwatch_dev['users'].find({:provider=>"github", :uid=>1573})
Started GET "/auth/github/callback?code=4334bab983hd5fec19dd" for 127.0.0.1 at 2011-07-25 22:27:36 +0200
Processing by SessionsController#create as HTML
Parameters: {"code"=>"4334bab983hd5fec19dd", "provider"=>"github"}
Redirected to http://localhost:3001/
Completed 302 Found in 255ms
MONGODB gitwatch_dev['users'].find({:_id=>BSON::ObjectId('4e23114b1d41c80f180005b2')})
Started GET "/" for 127.0.0.1 at 2011-07-25 22:27:39 +0200
Processing by HomeController#index as HTML
Rendered home/index.html.haml within layouts/application (415.6ms)
Completed 200 OK in 890ms (Views: 428.6ms | ActiveRecord: 0.0ms)
私の場合の解決策は次のようなものです:
app/controllers/errors_controller.rb 内
class ErrorsController < ApplicationController
def error
render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false
end
end
config/routes.rb の一番下に追加
match '/auth/:provider' => 'errors#error'
...オムニウス最終ルート後
`match "/auth/:provider/callback" => "sessions#create"`
オレグ・ハバロフFederico Gonzalez
に感謝します
これが他の誰かに役立つことを願っています;-)
さようならルカ・G・ソアーヴェ