Monday, May 13, 2024
HomeRuby On RailsWeb page Not Discovered | Drifting Ruby

Web page Not Discovered | Drifting Ruby


# Terminal
contact tmp/errors-dev.txt
rails g controller errors not_found unprocessable_entity internal_server_error
cp app/views/layouts/software.html.erb app/views/layouts/errors.html.erb
# config/environments/growth.rb
if Rails.root.be part of("tmp/errors-dev.txt").exist?
  config.consider_all_requests_local = false
else
  config.consider_all_requests_local = true
finish
# config/software.rb
config.exceptions_app = self.routes
# config/routes.rb
match "/404", to: "errors#not_found", by way of: :all
match "/422", to: "errors#unprocessable_entity", by way of: :all
match "/500", to: "errors#internal_server_error", by way of: :all
# app/controllers/errors_controller.rb
class ErrorsController < ActionController::Base
  # structure "errors"

  def not_found
  finish

  def unprocessable_entity
  finish

  def internal_server_error
  finish
finish
# app/views/layouts/errors.html.erb
<!DOCTYPE html>
<html>
  <head>
    <title>Drifting Ruby</title>
    <meta title="viewport" content material="width=device-width,initial-scale=1">
    <%= stylesheet_link_tag "software", "data-turbo-track": "reload" %>
  </head>

  <physique class="bg-light">
    <div class="container d-flex flex-column justify-content-center align-items-center" fashion="peak: 100vh;">
      <%= yield %>
    </div>
  </physique>
</html>
# app/views/errors/internal_server_error.html.erb
<%= image_tag "500.png", class: "img-fluid" %>

<p class="lead text-muted">It isn't you. One thing went flawed on our finish.</p>
<%= link_to "Again to house", root_path, class: "btn btn-primary" %>
# app/views/errors/not_found.html.erb
<%= image_tag "404.png", class: "img-fluid" %>

<p class="lead text-muted">
  We're sorry, however the web page you had been searching for would not exist.
</p>
<%= link_to "Again to house", root_path, class: "btn btn-primary" %>
# public/404.html
<!DOCTYPE html>
<html>

<head>
  <title>404 Not Discovered</title>
  <hyperlink href="https://www.driftingruby.com/bootstrap.min.css" rel="stylesheet">
</head>

<physique class="bg-light">
  <div class="container d-flex flex-column justify-content-center align-items-center" fashion="peak: 100vh;">
    <img class="img-fluid" src="/404.png">
    <p class="lead text-muted">We're sorry, however the web page you had been searching for would not exist.</p>
    <a href="https://www.driftingruby.com/" class="btn btn-primary">Again to House</a>
  </div>
</physique>

</html>
# public/500.html
<!DOCTYPE html>
<html>

<head>
  <title>500 Inner Server Error</title>
  <hyperlink href="https://www.driftingruby.com/bootstrap.min.css" rel="stylesheet">
</head>

<physique>
  <div class="container">
    <img src="/500.png" class="img-fluid">
    <p>We're sorry, however one thing went flawed.</p>
    <a href="https://www.driftingruby.com/">Again to House</a>
  </div>
</physique>

</html>
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments