Redirect User to Signup

前端 未结 5 956
没有蜡笔的小新
没有蜡笔的小新 2021-02-05 20:47

Using before_action :authenticate_user! to check if user logged in. But it sends users to login instead of signup.

Tried different

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-05 21:02

    What you are looking for is a referer. Having your before_filter working, you can override the Devise's after_sign_up_path_for:

    def after_sign_up_path_for(user)
      request.referer
    end
    

    EDIT

    Since request.referer is somehow not working, I think you could go with a session-based solution:

    def auth_user
      session[:before_sign_up_path] = request.fullpath
      redirect_to new_user_registration_url unless user_signed_in?
    end
    
    def after_sign_up_path_for(user)
      session[:before_sign_up_path]
    end
    

提交回复
热议问题