mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-21 22:29:38 +02:00
* fix: escape button handler * feat: location logic for settings page * fix: linting errors * fix: linting error * refactor: settings test
31 lines
542 B
Ruby
31 lines
542 B
Ruby
module StoreLocation
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
helper_method :previous_path
|
|
before_action :store_return_to
|
|
after_action :clear_previous_path
|
|
end
|
|
|
|
def previous_path
|
|
session[:return_to] || fallback_path
|
|
end
|
|
|
|
private
|
|
|
|
def store_return_to
|
|
if params[:return_to].present?
|
|
session[:return_to] = params[:return_to]
|
|
end
|
|
end
|
|
|
|
def clear_previous_path
|
|
if request.fullpath == session[:return_to]
|
|
session.delete(:return_to)
|
|
end
|
|
end
|
|
|
|
def fallback_path
|
|
root_path
|
|
end
|
|
end
|