module Mumuki::Laboratory::Controllers::ActionRedirector

Public Instance Methods

redirect_after!(action, fallback_location: root_path) click to toggle source
# File lib/mumuki/laboratory/controllers/action_redirector.rb, line 6
def redirect_after!(action, fallback_location: root_path)
  redirection_variable = redirection_variable_for(action)
  destination = session.delete(redirection_variable).presence
  redirect_to(destination || fallback_location)
end
save_location_before!(action) click to toggle source
# File lib/mumuki/laboratory/controllers/action_redirector.rb, line 2
def save_location_before!(action)
  session[redirection_variable_for(action)] = origin
end

Private Instance Methods

origin() click to toggle source
# File lib/mumuki/laboratory/controllers/action_redirector.rb, line 18
def origin
  Addressable::URI.heuristic_parse(request.path).to_s
end
redirection_variable_for(action) click to toggle source
# File lib/mumuki/laboratory/controllers/action_redirector.rb, line 14
def redirection_variable_for(action)
  "redirect_after_#{action}"
end