Skip to content

Commit 5a6566d

Browse files
committed
エラー表示をヘルパー化
・ErrorsHelperにerror_title/error_descメソッドを追加 ・local_assigns[:status_code]をもとに@title/@descをセット ・provideでレイアウト用のタイトル・ディスクリプションを連携
1 parent d064907 commit 5a6566d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

app/helpers/errors_helper.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module ErrorsHelper
2+
def error_title(code)
3+
case code
4+
when 404 then "ページが見つかりませんでした... 🥺💦"
5+
when 422 then "リクエストが処理できませんでした… 😢"
6+
when 500 then "予期しないエラーが発生しました 😵‍💫"
7+
else "予期せぬエラーが発生しました…😵"
8+
end
9+
end
10+
11+
def error_desc(code)
12+
case code
13+
when 404 then "ページが削除された可能性があります 🤔💭"
14+
when 422 then "入力内容に誤りがあるか、リクエストが正しく送信されなかった可能性があります。"
15+
when 500 then "申し訳ありません。サーバーで問題が発生しています。"
16+
else "しばらく経ってから再度お試しください。"
17+
end
18+
end
19+
end

0 commit comments

Comments
 (0)