Sha256: 083de6db765de2682bae26a160be54f70a846d684f91f00e6038fcade5f51bbb

Contents?: true

Size: 506 Bytes

Versions: 14

Compression:

Stored size: 506 Bytes

Contents

module Redirectify
  extend ActiveSupport::Concern

  included do
    helper_method :back_or_default_path
  end

  def back_or_default_path(default_path)
    referer_path || default_path
  end

  def referer_path
    return if request.referer.blank?

    routing_hash = Rails.application.routes.recognize_path(request.referer)
    referer_uri = request.referer.dup.delete(['?', URI.parse(request.referer).query].join)

    request.referer if url_for(routing_hash) == referer_uri
  rescue
    nil
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
comfortable_mexican_loveseat-0.1.1 app/controllers/concerns/redirectify.rb
comfortable_mexican_loveseat-0.1.0 app/controllers/concerns/redirectify.rb
comfortable_mexican_loveseat-0.0.23 app/controllers/concerns/redirectify.rb
comfortable_mexican_loveseat-0.0.22 app/controllers/concerns/redirectify.rb
comfortable_mexican_loveseat-0.0.21 app/controllers/concerns/redirectify.rb
comfortable_mexican_loveseat-0.0.20 app/controllers/concerns/redirectify.rb
comfortable_mexican_loveseat-0.0.19 app/controllers/concerns/redirectify.rb
comfortable_mexican_loveseat-0.0.18 app/controllers/concerns/redirectify.rb
comfortable_mexican_loveseat-0.0.17 app/controllers/concerns/redirectify.rb
comfortable_mexican_loveseat-0.0.16 app/controllers/concerns/redirectify.rb
comfortable_mexican_loveseat-0.0.15 app/controllers/concerns/redirectify.rb
comfortable_mexican_loveseat-0.0.14 app/controllers/concerns/redirectify.rb
comfortable_mexican_loveseat-0.0.13 app/controllers/concerns/redirectify.rb
comfortable_mexican_loveseat-0.0.12 app/controllers/concerns/redirectify.rb