少於 1 分鐘閱讀

前言

本次需求,在facebook登入後,仍希望轉至使用者編輯頁面,讓使用者補填電話及密碼等資訊,否則該帳號不予以啟動。

override after_sign_in_path_for

class ApplicationController < ActionController::Base protect_from_forgery with: :exception

def after_sign_in_path_for(resource) if resource.phone.nil? edit_user_path else super end end end

參考

  1. http://stackoverflow.com/questions/32471885/how-does-sign-in-and-redirect-in-devise-work
  2. https://github.com/plataformatec/devise/wiki/How-To:-redirect-to-a-specific-page-on-successful-sign-in

更新時間:

留言