페이스 북에 외부 로그인을 추가하려고하지만 홈 페이지가 나를 페이스 북 페이지로 올바르게 안내 할 때마다 ,하지만 다음과 같은 오류가 발생하고 그것이 무엇인지 이해할 수 없었습니다.Ruby on Rails : 사용자 :: OmniauthCallbacksController # facebook에이 요청 형식 및 변형에 대한 템플릿이 누락되었습니다.
"사용자 :: OmniauthCallbacksController # facebook에이 요청 형식 및 변형에 대한 템플릿이 없습니다. request.formats : ["text/html "] request.variant : [] 참고 : XHR/Ajax 또는 API 요청의 경우이 액션은 일반적으로 204 개의 No Content : 빈 흰색 화면으로 응답합니다. 웹 브라우저에서이 텍스트를로드하고 있기 때문에 실제로는 템플릿을 렌더링하지 않을 것으로 예상 했으므로 추가로 오류가 표시됩니다. 204 콘텐츠가 없다고 기대하는 경우 XHR 또는 API 요청에서 얻은 결과입니다.
"That's what you'll get from an XHR or API request. Give it a shot."
raise ActionController::UnknownFormat, message
else
logger.info "No template found for #{self.class.name}\##{action_name}, rendering head :no_content" if logger
super
이
내 컨트롤러class Users::OmniauthCallbacksController < ApplicationController
def facebook
@User = User.from_omniauth(request.env["omniauth.auth"])
if @User.persisted?
@User.remember_me = true
sign_in_and_redirect @User, event: :authentication
end
end
end
이 사용자 모델입니다.
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 => [:facebook]
def self.from_omniauth(auth)
where(provider: auth[:provider], uid: auth[:uid]).first_or_create do |user|
if auth[:info]
user.email = auth[:info][:email]
user.name = auth[:info][:name]
end
user.password = Devise.friendly_token[0,20]
end
end
has_many :articles , :dependent => :destroy
end
와 나는 설정/초기화/divise.rb에서이 줄을 추가
config.omniauth :facebook, '504432376574467', 'b2bb80641fcc2ca4d28e48c5ce*******'