Last active
March 30, 2023 05:06
-
-
Save westonganger/ef51c005c8a033436a1b8f074bf37463 to your computer and use it in GitHub Desktop.
Get Previous Route in Rails 3/4+ App
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ApplicationController < ActionController::Base | |
| after_filter :set_route_info | |
| def set_route_info | |
| session[:return_to] = request.url | |
| prev_route = Rails.application.routes.recognize_path(URI(session[:return_to]).path) | |
| session[:previous_controller] = prev_route[:action] | |
| session[:previous_action] = prev_route[:action] | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment