Sha256: 0187ac76555eb72f652c590d22e10dc7108091643c1e6371a2058d456852b0be

Contents?: true

Size: 405 Bytes

Versions: 2

Compression:

Stored size: 405 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_by_uri(request.original_url)
      redirect_to redirect.destination, :status => :moved_permanently
    else
      handle_request_error(error)
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tb_redirects-0.9.0 app/controllers/concerns/tb_redirects/handle_redirects.rb
tb_redirects-0.0.1 app/controllers/concerns/tb_redirects/handle_redirects.rb