Ruby on rails twitter/Facebook身份验证出现Rails 4错误。设计

Ruby on rails twitter/Facebook身份验证出现Rails 4错误。设计,ruby-on-rails,devise,twitter,omniauth,facebook-authentication,Ruby On Rails,Devise,Twitter,Omniauth,Facebook Authentication,我正在与Desive合作,我正在尝试允许用户使用twitter/facebook注册。我很困惑,因为我一直在\ 没有路由匹配{:controller=>“authentications”,:action=>“passthru”,:provider=>:twitter,:format=>nil}缺少必需的键:[:provider] Routes.rb devise_for :users,controllers: {omniauth_callbacks: "authentications", re

我正在与Desive合作,我正在尝试允许用户使用twitter/facebook注册。我很困惑,因为我一直在\ 没有路由匹配{:controller=>“authentications”,:action=>“passthru”,:provider=>:twitter,:format=>nil}缺少必需的键:[:provider]

Routes.rb

 devise_for :users,controllers: {omniauth_callbacks: "authentications", registrations: "registrations"}
AuthenticationController.rb

class AuthenticationsController < ApplicationController
  def index
    @authentications = Authentication.all
  end

  def create
    @authentication = Authentication.new(params[:authentication])
    if @authentication.save
      redirect_to authentications_url, :notice => "Successfully created authentication."
    else
      render :action => 'new'
    end
  end

  def destroy
    @authentication = Authentication.find(params[:id])
    @authentication.destroy
    redirect_to authentications_url, :notice => "Successfully destroyed authentication."
  end
  def twitter
raise omni = request.env["omniauth.auth"].to_yaml
end
end
类身份验证控制器“已成功创建身份验证。”
其他的
呈现:操作=>“新建”
结束
结束
def销毁
@authentication=authentication.find(参数[:id])
@身份验证。销毁
重定向到身份验证\u url,:notice=>“已成功销毁身份验证。”
结束
def推特
将omni=request.env[“omniauth.auth”]提升到
结束
结束

我假设您在用户模型中有如下内容:;因此,您将遇到此路由错误

devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable,
         :validatable, :omniauthable,
         :omniauth_providers => [:facebook],
         :omniauth_providers => [:twitter]
将其更改为以下内容:

devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable,
         :validatable, :omniauthable,
         :omniauth_providers => [:facebook, :twitter]

我在跟踪omniauth,我

class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable
  devise :omniauthable, :omniauth_providers => [:google]
end
class用户[:谷歌]
结束
但只需要一条设计线,如下所示:

class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable,
         :omniauthable, :omniauth_providers => [:google]
end
class用户[:谷歌]
结束

好的,首先要阅读这本非常详细的指南。如果还有其他问题,请提问,似乎你走错了路