Module: JumpBack::Redirection

Defined in:
lib/jump_back/redirect_back.rb,
lib/jump_back/return_to_referer.rb

Instance Method Summary collapse

Instance Method Details

#clear_refererObject



16
17
18
# File 'lib/jump_back/return_to_referer.rb', line 16

def clear_referer
  session.delete(:jump_back_stored_referer)
end

#redirect_back(path = root_path, options = {}) ⇒ Object



5
6
7
8
# File 'lib/jump_back/redirect_back.rb', line 5

def redirect_back(path=root_path, options={})
  options = OptionsParser.new(path: path, options: options, default: root_path)
  redirect_to PathFinder.new(request, options.path, options.jump_back_options).path, options.redirect_options
end

#return_to_referer(path = root_path, options = {}) ⇒ Object



11
12
13
14
# File 'lib/jump_back/return_to_referer.rb', line 11

def return_to_referer(path=root_path, options={})
  options = OptionsParser.new(path: path, options: options, default: root_path)
  session[:jump_back_stored_referer] ? redirect_to(clear_referer, options.redirect_options) : redirect_to(options.path, options.redirect_options)
end

#save_refererObject



7
8
9
# File 'lib/jump_back/return_to_referer.rb', line 7

def save_referer
  session[:jump_back_stored_referer] ||= request.referer
end