设计& Rails 3.1 中的omniauth Facebook 身份验证
我已按照本指南让 Devise Facebook 身份验证正常工作,并且我现在已经到了我无法理解的地步,我需要一些帮助。
我收到“使用 Facebook 登录”链接,但单击它时出现以下错误,告诉我路线有问题
未知操作
找不到路径“/users/auth/facebook”的设备映射。也许您忘记将路线包装在范围块内?例如: devise_scope :user 匹配“/some/route”=> “some_devise_controller”结束
这是我的路线文件
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru'
root :to => 'home#index'
编辑:
通过将路线更改为解决了该问题
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" } do
get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru'
end
root :to => 'home#index'
现在我遇到了下一个错误,让 Facebook 身份验证正常工作,但是当从“允许应用程序屏幕”返回时,ruby 会抛出...
未定义方法“已关闭?”对于 nil:NilClass
activesupport (3.1.0.rc8) lib/active_support/whiny_nil.rb:48:in
method_missing' /opt/local/lib/ruby/1.8/net/http.rb:1060:in
请求' 法拉第 (0.6.1) lib/faraday/adapter/net_http.rb:51:incall' 法拉第 (0.6.1) lib/faraday/request/url_encoded.rb:14:in
call' 法拉第 (0.6.1) lib/faraday/request.rb:88:inrun' 法拉第 (0.6.1) lib/faraday/request.rb:28:in
run' 法拉第 (0.6.1) lib/faraday/connection.rb:170:inrun_request' oauth2 (0.4.1) lib/oauth2/client.rb:63:in
请求'...
这是使用 Rails 3.1.0rc8 和 ruby 1.9.2
I've followed this guide for getting Devise Facebook authentication to work and I've now come to a point where I can't understand and I would like some help.
I get the Sign in with Facebook link but clicking on it I get the following error, telling me there's something wrong with the routes
Unknown action
Could not find devise mapping for path "/users/auth/facebook". Maybe you forgot to wrap your route inside the scope block? For example: devise_scope :user do match "/some/route" => "some_devise_controller" end
Here is my routes file
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru'
root :to => 'home#index'
Edit:
Solved that issue by changing the routes to
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" } do
get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru'
end
root :to => 'home#index'
Now I got the next error getting the Facebook auth to work but when coming back from the "Allow app screen" ruby throws...
undefined method `closed?' for nil:NilClass
activesupport (3.1.0.rc8) lib/active_support/whiny_nil.rb:48:in
method_missing'
request'
/opt/local/lib/ruby/1.8/net/http.rb:1060:in
faraday (0.6.1) lib/faraday/adapter/net_http.rb:51:incall'
call'
faraday (0.6.1) lib/faraday/request/url_encoded.rb:14:in
faraday (0.6.1) lib/faraday/request.rb:88:inrun'
run'
faraday (0.6.1) lib/faraday/request.rb:28:in
faraday (0.6.1) lib/faraday/connection.rb:170:inrun_request'
request'
oauth2 (0.4.1) lib/oauth2/client.rb:63:in...
This is using Rails 3.1.0rc8 and ruby 1.9.2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我昨天刚刚完成我的应用程序的omniauth登录,使用完全相同的指南和rails 3.1 Final
不确定你的路线是否正确,我的看起来像这样:
在我的
devise_for :users
块中,我放置了标志登录并注销,因为我使用的是 OmniAuth,没有其他身份验证该指南还指出
get '/users/auth/:provider'
行应该位于devise_scope 中:user
不确定这会解决你的问题,但至少我想指出这些不适合评论的观点
I just finished yesterday my omniauth login for my app, using exactly the same guide and rails 3.1 final
Not sure you did your routes ok, mine look like this:
In my
devise_for :users
block I put the sign in and sign out because I'm using OmniAuth without other authenticationsThe guide also sais that the
get '/users/auth/:provider'
line should be in adevise_scope :user
Not sure this will fix your problem, but at least I wanted to state out these points, which don't fit in a comment