i'm using devise 4.0.0 , rails 4.2.6. trying devise redirect page user @ before went devise log in page or before clicked log out (which link destroy_user_session_path). have read devise how https://github.com/plataformatec/devise/wiki/how-to:-redirect-back-to-current-page-after-sign-in,-sign-out,-sign-up,-update says it's out of date , should read code https://github.com/plataformatec/devise/blob/master/lib/devise/controllers/store_location.rb did, didn't me figure out needed do. have searched through bunch of q/as, many of them outdated. 1 of them worked me sign_in. added:
before_filter :store_current_location, :unless => :devise_controller? private def store_current_location store_location_for(:user, request.url) end
to applicationcontroller. sign out still returning root. overrode after_sign_out_path_for(resource) , found out stored_location_for(resource) nil. can't figure out why. other q/as suggested:
private def after_sign_out_path_for(resource) stored_location_for(resource) || request.referrer || root_path end
which seems trick through request.referrer part. can't figure out stored location being deleted. in devise code linked above, stored location deleted when retrieve doesn't seem happening.
i'm new rails, there obvious thing i'm missing. can explain me why stored_location_for(resource) nil? or it's being deleted?
try
request.referrer
in order previous url