Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Omniauth错误:没有与[GET]匹配的路由/auth/facebook";_Ruby On Rails_Ruby_Ruby On Rails 4_Omniauth - Fatal编程技术网

Ruby on rails Omniauth错误:没有与[GET]匹配的路由/auth/facebook";

Ruby on rails Omniauth错误:没有与[GET]匹配的路由/auth/facebook";,ruby-on-rails,ruby,ruby-on-rails-4,omniauth,Ruby On Rails,Ruby,Ruby On Rails 4,Omniauth,我的应用程序在三周前运行良好,但在重新使用它时,我在尝试通过Facebook登录后出现以下错误: No route matches [GET] "/auth/facebook" 不知道发生了什么事。我看过Stackoverflow,但只找到了与Desive gem相关的帮助 注意:我没有使用Desive gem。 我的应用程序基于Ruby 2.0和Rails 4 我的gemlock文件显示了omniauth的以下版本: oauth2 (0.8.1) faraday (~>

我的应用程序在三周前运行良好,但在重新使用它时,我在尝试通过Facebook登录后出现以下错误:

No route matches [GET] "/auth/facebook"
不知道发生了什么事。我看过Stackoverflow,但只找到了与Desive gem相关的帮助

注意:我没有使用Desive gem。

我的应用程序基于Ruby 2.0和Rails 4

我的gemlock文件显示了omniauth的以下版本:

  oauth2 (0.8.1)
      faraday (~> 0.8)
      httpauth (~> 0.1)
      jwt (~> 0.1.4)
      multi_json (~> 1.0)
      rack (~> 1.2)
    omniauth (1.1.4)
      hashie (>= 1.2, < 3)
      rack
    omniauth-facebook (1.4.0)
      omniauth-oauth2 (~> 1.0.2)
    omniauth-oauth2 (1.0.3)
      oauth2 (~> 0.8.0)
      omniauth (~> 1.0) 
而不是这个

match 'auth/:provider/callback', to: 'sessions#create', via: [:get, :post]
match 'auth/failure', to: redirect('/'), via: [:get, :post]
match 'signout', to: 'sessions#destroy', as: 'signout', via: [:get, :post]
试试这个

 get 'auth/:provider/callback' => 'sessions#create'
 get 'auth/failure' => redirect('/')
 get 'signout' => 'sessions#destroy', as: 'signout'

嗨,吉顿。我在别处见过这个答案,但我不确定它是否适用于我,因为我没有使用Desive gem。我没有一个“全授权”的评论。我很感激你删除你的说明的第二部分,但我仍然无法让它工作添加到我的初始化行。我创建了config/initializers/omniauth.rb并输入了您输入的代码,重新启动了Rails服务器,错误仍然是一样的。请尝试我放在答案框中的那个,我找到了答案。omniauth.rb初始值设定项文件以某种方式被删除(它位于.gitignore中),因此我必须重新创建该文件。谢谢你。我对你的答案投了赞成票。
 get 'auth/:provider/callback' => 'sessions#create'
 get 'auth/failure' => redirect('/')
 get 'signout' => 'sessions#destroy', as: 'signout'