omniauth をアプリケーションに統合しようとしていますが、devise を使用していません。私は Ryan Bates のスクリーン キャスト OmniAuth Part 2 #236 に従っていますが、彼は全員がデバイスを使用していると想定しています。authentication_controller.rb には、デバイス固有のコードがあります
def create
omniauth = request.env["omniauth.auth"]
authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])
if authentication
flash[:notice] = "Signed in successfully."
sign_in_and_redirect(:user, authentication.user)
elsif current_user
current_user.authentications.create!(:provider => omniauth['provider'], :uid => omniauth['uid'])
flash[:notice] = "Authentication successful."
redirect_to authentications_url
else
user = User.new
user.apply_omniauth(omniauth)
if user.save
flash[:notice] = "Signed in successfully."
sign_in_and_redirect(:user, user)
else
session[:omniauth] = omniauth.except('extra')
redirect_to new_user_registration_url
end
end
終わり
そのsign_in_and_redirect
ページを更新すると、
undefined method `sign_in_and_redirect'
誰かがこれの回避策を知っていますか...私はレールにかなり慣れていないので、一歩一歩が理想的です。
また、DEVISE を使用せずに OmniAuth を統合することをカバーする優れたチュートリアルを誰かが知っている場合も、感謝します。