嘿即時嘗試將omniauth集成到我的應用程序,但我不使用設計。我跟隨瑞恩貝茨的屏幕投了OmniAuth第2部分#236,他假設每個人都在使用設計。在authentication_controller.rb還有就是制訂具體omniauth without devise rails cast 236
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'
沒有人知道一個解決這個問題的方法...即時通訊非常新的軌道,所以一步一步將是理想的。
謝謝你們,如果有人知道一個很好的教程,涵蓋集成OmniAuth沒有DEVISE會很好。
嘿感謝您的建議,但不登入的用戶它只是重定向到主頁 – user1502223
設置會話[:user_id]是什麼設置用戶登錄。 –
感謝您的鏈接,但我會穿過他們嘗試不同的方法。 – user1502223