use*_*030 4 twitter ruby-on-rails devise omniauth facebook-authentication
我正在使用设计,我正在尝试允许用户使用twitter/facebook注册.我很困惑,因为我一直得到\没有路由匹配{:controller =>"authentications",:action =>"passthru",:provider =>:twitter,:format => nil}缺少必需的密钥:[:provider]
的routes.rb
devise_for :users,controllers: {omniauth_callbacks: "authentications", registrations: "registrations"}
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
Dee*_*ane 16
我假设你在用户模型中有类似下面的东西; 因此,您收到此路由错误.
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable,
:validatable, :omniauthable,
:omniauth_providers => [:facebook],
:omniauth_providers => [:twitter]
Run Code Online (Sandbox Code Playgroud)
将其更改为以下内容:
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable,
:validatable, :omniauthable,
:omniauth_providers => [:facebook, :twitter]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2518 次 |
| 最近记录: |