Sha256: de2ff2fddd6f27d0902018108085150e272e0000c52a430e7fef8031c121a807

Contents?: true

Size: 400 Bytes

Versions: 3

Compression:

Stored size: 400 Bytes

Contents

module TbRedirects::HandleRedirects
  extend ActiveSupport::Concern

  included do
    rescue_from Spud::NotFoundError, with: :check_for_applicable_redirect
  end

  def check_for_applicable_redirect(error)
    if redirect = TbRedirect.find_with_uri(request.original_url)
      redirect_to redirect.destination, status: :moved_permanently
    else
      handle_request_error(error)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tb_redirects-1.0.1 app/controllers/concerns/tb_redirects/handle_redirects.rb
tb_redirects-1.0 app/controllers/concerns/tb_redirects/handle_redirects.rb
tb_redirects-1.0.beta1 app/controllers/concerns/tb_redirects/handle_redirects.rb