Skip to content

メンター用プロフィール公開設定のON/OFFスイッチの反転と属性名変更 #8553

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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

sekito1107
Copy link
Contributor

@sekito1107 sekito1107 commented Apr 11, 2025

Issue

#8528

概要

430437290-efb49f01-1cb2-4c1c-9765-c1b7b8050f36
  1. UIの直感性向上:
    従来のUIでは「プロフィール非公開 (OFF)」という表現が、プロフィールの公開状態を示すものとして直感的ではありませんでした (画像参照)。
    これを改善するため、スイッチの表示を「公開」状態を示す「ON」に変更し、UIの直感性を高めました。

  2. 文言の修正:
    UIの変更に合わせて、プロフィールの公開設定に関する案内文を修正しました。

  3. データモデルの変更:
    直感的なUIを実現するため、プロフィールの公開状態を保存する属性名を変更し、既存の真偽値を反転させました。
    ( 元の属性名 hide_mentor_profileshow_mentor_profile に変更し、真偽値を反転)

変更確認方法

  1. feature/invert-profile-visibility-switchをローカルに取り込む
    • git checkout feature/invert-profile-visibility-switch
  2. bin/rails db:migrate でデータベースを更新する
  3. foreman start -f Procfile.dev でローカル環境を立ち上げる
  4. id:komagata pass:testtest でログインする
  5. http://localhost:3000/current_user/edit にアクセスし、メンター紹介用公開プロフィールの欄が以下の画像のようになっていることを確認する
    image
  6. ログアウトする
  7. http://localhost:3000/ にアクセスし、下部へとスクロールし、メンター顧問 の欄に適切にプロフィールが表示されているのを確認する

Screenshot

変更前

image

変更後

image

@sekito1107 sekito1107 force-pushed the feature/invert-profile-visibility-switch branch from 81a78f8 to 0748586 Compare April 11, 2025 12:05
@sekito1107 sekito1107 changed the title メンタープロフィールの公開可否に利用している属性値を変更 メンタープロフィールの公開可否に利用している属性名を変更 Apr 11, 2025
@sekito1107 sekito1107 force-pushed the feature/invert-profile-visibility-switch branch from 0748586 to c5d6ae6 Compare April 11, 2025 23:53
@sekito1107 sekito1107 changed the title メンタープロフィールの公開可否に利用している属性名を変更 メンター用プロフィール公開設定のON/OFFスイッチの反転と属性名変更 Apr 12, 2025
@sekito1107 sekito1107 requested a review from kushimegu April 12, 2025 03:06
@sekito1107 sekito1107 marked this pull request as ready for review April 12, 2025 03:08
@sekito1107
Copy link
Contributor Author

@kushimegu
良ければこちらレビューお願いできないでしょうかー?
急ぎではありませんのでご都合のつく時で大丈夫です
ご検討お願いしますー🙏

@kushimegu
Copy link
Contributor

@sekito1107
大丈夫です!
近日中にレビューさせていただきます。

@kushimegu
Copy link
Contributor

動作は確認できたのですが、コードで気になったことがあったのでコメントしました!

@sekito1107
Copy link
Contributor Author

@kushimegu
レビューありがとうございます!
恐らくですが、レビューして頂いたコメントがpendingになっていてこちらから見ることができませんー。

参考:https://qiita.com/Ryo-0131/items/29080f242256ab3f1375

Copy link
Contributor

@kushimegu kushimegu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

すみません、pendingになっていることに気づかず…。Submit reviewしたので見えるかなと思います。確認をお願いします。

def down
execute "UPDATE users SET show_mentor_profile = NOT show_mentor_profile"
end
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

マイグレーションファイルを書き換えるわけにはいかないと思うのでただの意見なんですが、

  1. executeでSQLを書くよりupdate_allした方がコードが短くなるのでは
  2. Rails Guideではreversibleメソッドとchangeを使う代わりにup/downも使えると書かれているのでreversibleを使えるならそちらで良いのかも

と思ったのですが、どうでしょうか?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ご指摘ありがとうございます!

マイグレーションファイルについては、本番環境で既に運用されている場合は書き換えずに新しいマイグレーションを追加するほうが良いと思いますが、今回は開発ブランチでの作業なので、書き換えでも問題ないと判断しました👍

また、update_all を使う方がより Rails っぽくて読みやすいと感じたので、そちらを取り入れさせていただきました!

reversible についても確かにその書き方は可能だと思いますが、「reversible を優先すべき」というよりは、処理の意図が伝わりやすい書き方を選ぶべきだと考えています。
今回のようにシンプルな反転処理であれば、up/down を使って明示的に書いたほうが分かりやすいかなと思ったのですが、いかがでしょうか?🙏

Copy link
Contributor Author

@sekito1107 sekito1107 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kushimegu
レビューありがとうございます、修正に伴いコメントしましたのでご確認お願いしますー🙏

def down
execute "UPDATE users SET show_mentor_profile = NOT show_mentor_profile"
end
end
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ご指摘ありがとうございます!

マイグレーションファイルについては、本番環境で既に運用されている場合は書き換えずに新しいマイグレーションを追加するほうが良いと思いますが、今回は開発ブランチでの作業なので、書き換えでも問題ないと判断しました👍

また、update_all を使う方がより Rails っぽくて読みやすいと感じたので、そちらを取り入れさせていただきました!

reversible についても確かにその書き方は可能だと思いますが、「reversible を優先すべき」というよりは、処理の意図が伝わりやすい書き方を選ぶべきだと考えています。
今回のようにシンプルな反転処理であれば、up/down を使って明示的に書いたほうが分かりやすいかなと思ったのですが、いかがでしょうか?🙏

@sekito1107 sekito1107 requested a review from kushimegu April 19, 2025 05:32
Copy link
Contributor

@kushimegu kushimegu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

マイグレーションファイルについては、本番環境で既に運用されている場合は書き換えずに新しいマイグレーションを追加するほうが良いと思いますが、今回は開発ブランチでの作業なので、書き換えでも問題ないと判断しました👍

捕捉と修正ありがとうございます!

reversibleを使うかup/downを使うかでどっちが読みやすいかは正直判断できないのですが、特にどちらでも問題ないと思うのでこれでApproveとさせていただきます。

@sekito1107
Copy link
Contributor Author

@kushimegu
レビューありがとうございました🙇‍♂️

@komagata
こちらレビューお願いしますー。

@sekito1107 sekito1107 requested a review from komagata April 22, 2025 14:35
@sekito1107 sekito1107 force-pushed the feature/invert-profile-visibility-switch branch from da88d11 to 2966581 Compare April 22, 2025 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants