Sha256: bc6e3200d19b384fa2c2829035db89b5b82ce1736d5516baf2da6be1cef6c038

Contents?: true

Size: 448 Bytes

Versions: 7

Compression:

Stored size: 448 Bytes

Contents

module NotFound
  extend ActiveSupport::Concern

  included do
    rescue_from Mongoid::Errors::DocumentNotFound do |exception|
      redirect_or_not_found()
    end

    def redirect_or_not_found
      redirect = Character::Redirect.where(path: request.path).first
      if redirect
        redirect_to redirect.destination, status: redirect.type
      else
        raise ActionController::RoutingError.new('Not Found')
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
character-1.0.6 app/controllers/concerns/not_found.rb
character-1.0.5 app/controllers/concerns/not_found.rb
character-1.0.4 app/controllers/concerns/not_found.rb
character-1.0.3 app/controllers/concerns/not_found.rb
character-1.0.2 app/controllers/concerns/not_found.rb
character-1.0.1 app/controllers/concerns/not_found.rb
character-1.0.0 app/controllers/concerns/not_found.rb