I am working with devise, and I am trying to allow users to signup using twitter/facebook. I am very confused because I keep getting \ No route matches {:controller=>"authentications", :action=>"passthru", :provider=>:twitter, :format=>nil} missing required keys: [: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
I assume you've something like the below in the User model; because of this, you are getting this routing error.
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable,
:validatable, :omniauthable,
:omniauth_providers => [:facebook],
:omniauth_providers => [:twitter]
Change it to the following:
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable,
:validatable, :omniauthable,
:omniauth_providers => [:facebook, :twitter]
I was following the omniauth example on github and I had
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
but needed to only have the one devise line as follows:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With