-
-
Notifications
You must be signed in to change notification settings - Fork 108
Rambulanceを使って404/500/422ページを整備 #1702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@nacchan99 PR ありがとうございます!可能そうならテストも追加してもらえると助かります!(>人< )✨(View の文言は頻繁に更新されるので、文言を頻繁に更新してもその都度テストを修正する必要がないテストだと嬉しいです! 🙇 ) |
@yasulab |
@rakuda-san-desu まだRSpec周りは手探りで進めている部分が多く、特にテストの書き方には自信がないので、書き方や構成に違和感があればご指摘いただけると嬉しいです…!🙇♀️ お手隙の際によろしくお願いします🙌 |
</div> | ||
<script async="" await="" src="https://platform.twitter.com/widgets.js" charset="utf-8"></script> | ||
</section> | ||
<%= render 'errors/footer_links_and_timeline' %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error 専用の Partial にしては個々に分割しすぎな印象なので (個々に分けるメリットより個々に分けたことよる煩雑さが上回って僕がメンテするとき辛いので)、 共通化できる箇所のみを1つの Partial にまとめる ようにしていただけると助かります!(>人< )✨
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
実装ありがとうございます!
いくつかコメントしましたが、動作は良さそうです🙆♀️
app/controllers/errors_controller.rb
Outdated
@@ -0,0 +1,15 @@ | |||
class ErrorsController < ApplicationController | |||
layout 'application' # エラー画面にも通常のアプリと同じレイアウトを適用 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
このコメントはカットして良さそうです👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ご指摘ありがとうございます!
こちらのコミットで対応済みです🙌 4b52ff7
app/controllers/errors_controller.rb
Outdated
layout 'application' # エラー画面にも通常のアプリと同じレイアウトを適用 | ||
|
||
def not_found | ||
render status: 404 # このアクションでは app/views/errors/not_found.html.erb が使用されます |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
他所も同様ですが、
該当する行の上にコメントを書くと、他の部分と統一されて良さそうです🛠️
# このアクションでは app/views/errors/not_found.html.erb が使用されます
render status: 404
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
統一しました🛠
対応コミットはこちらです→ 7e4737c
with_exceptions_app do | ||
get '/does_not_exist' | ||
end | ||
expect(response.status).to eq(404) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
「子どものためのプログラミング道場」など、必ず表示されるテキストが存在するかも確認しておくと、さらに安心できそうです👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
テストを追加しました🙌
092c3dd
よろしくお願いします!
Resolves #1407
🛠 対応内容
404, 500, 422のエラーページがそれぞれ適切に表示されるように設定しました。
🚨 エラーページの追加と表示確認
ErrorsController
を新しく作成not_found
→ 404internal_server_error
→ 500unprocessable_entity
→ 422app/views/errors/
に対応する.html.erb
ビューを作成not_found.html.erb
をベースに、他の2つのビューも統一デザインで作成config/application.rb
に Rambulance の設定を追記routes.rb
にmount Rambulance::Engine => "/"
を追加🖼️ 表示確認(スクリーンショット)
404

500

422
