Skip to content

Commit a4ce6e1

Browse files
committed
ErrorsController を新規作成(404/500/422用)
1 parent a39bdf6 commit a4ce6e1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class ErrorsController < ApplicationController
2+
layout 'application' # エラー画面にも通常のアプリと同じレイアウトを適用
3+
4+
def not_found
5+
render status: 404 # このアクションでは app/views/errors/not_found.html.erb が使用されます
6+
end
7+
8+
def internal_server_error
9+
render status: 500 # このアクションでは app/views/errors/internal_server_error.html.erb が使用されます
10+
end
11+
12+
def unprocessable_entity
13+
render status: 422 # このアクションでは app/views/errors/unprocessable_entity.html.erb が使用されます
14+
end
15+
end

0 commit comments

Comments
 (0)