# Devise 이전 페이지로 이동 사용자의 이전 페이지를 기억시키고 돌아가게 하려면 어떻게 해야할까요?
## ApplicationController 아래 코드를 참고. ``` # This example assumes that you have setup devise to authenticate a class named User. class ApplicationController < ActionController::Base before_action :store_user_location!, if: :storable_location? # The callback which stores the current location must be added before you authenticate the user # as `authenticate_user!` (or whatever your resource is) will halt the filter chain and redirect # before the location can be stored. before_action :authenticate_user! private # Its important that the location is NOT stored if: # - The request method is not GET (non idempotent) # - The request is handled by a Devise controller such as Devise::SessionsController as that could cause an # infinite redirect loop. # - The request is an Ajax request as this can lead to very unexpected behaviour. def storable_location? request.get? && is_navigational_format? && !devise_controller? && !request.xhr? end def store_user_location! # :user is the scope we are authenticating store_location_for(:user, request.fullpath) end end ``` ## 레퍼런스 + How To: Redirect back to current page after sign in, sign out, sign up, update (https://goo.gl/NSKq2)