Skip to content
This repository has been archived by the owner on Feb 20, 2022. It is now read-only.

Commit

Permalink
Merge pull request #263 from MYDRY/feature/add-error-page
Browse files Browse the repository at this point in the history
Add nothing route
  • Loading branch information
rkdora authored Feb 2, 2019
2 parents 3923c06 + 1bdce80 commit 9d66cf8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ class ApplicationController < ActionController::Base
include Jpmobile::ViewSelector
include UsersHelper

rescue_from ActiveRecord::RecordNotFound, with: :render_404
rescue_from ActionController::RoutingError, with: :render_404

def render_404
flash[:danger] = 'そのページは存在しません'
redirect_to root_path
end

def authorize
unless logged_in?
flash[:info] = 'ログインしてください'
Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@
resources :random_words_ideas
resources :mandal_ideas
resources :seas

get '*path' => 'application#render_404'
end

0 comments on commit 9d66cf8

Please sign in to comment.