Sha256: 0e64640242401db84bf463d86ccfc3153ef9b69c4539c07c12c48d8f39c08082

Contents?: true

Size: 560 Bytes

Versions: 2

Compression:

Stored size: 560 Bytes

Contents

require 'jump_back/options_parser'

module JumpBack
  
  module Redirection
    
    def save_referer
      session[:jump_back_stored_referer] ||= request.referer
    end
  
    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
  
    def clear_referer
      session.delete(:jump_back_stored_referer)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jump_back-0.3.2 lib/jump_back/return_to_referer.rb
jump_back-0.3.1 lib/jump_back/return_to_referer.rb