Open ryohakjae114 opened 3 weeks ago
[!IMPORTANT]
Review skipped
Auto reviews are disabled on base/target branches other than the default branch.
Please check the settings in the CodeRabbit UI or the
.coderabbit.yaml
file in this repository. To trigger a single review, invoke the@coderabbitai review
command.You can disable this status message by setting the
reviews.review_status
tofalse
in the CodeRabbit configuration file.
この変更は、ユーザーがポストに画像を添付できる新機能を導入しています。Active Storage
を使用して画像のアップロードと保存を実装し、画像のバリデーションを追加し、表示画面での画像表示をサポートするためにビューを更新しました。また、関連するテストも追加されました。
ファイル | 変更内容概要 |
---|---|
Gemfile |
image_processing のgemを追加 |
app/controllers/posts_controller.rb |
post_params メソッドで :picture パラメータを許可するように変更 |
app/models/post.rb |
has_one_attached :picture の関連付けとバリデーションメソッド allowed_picture_content_type を追加 |
app/views/posts/index.html.haml , show.html.haml |
画像表示のための変更、およびレイアウト調整 |
app/views/posts/new.html.haml |
新しいポスト作成フォームに画像入力フィールドを追加 |
app/views/shared/_post.html.haml |
画像が添付されているかどうかの条件チェックと画像タグの追加 |
app/views/shared/_posts.html.haml |
ポストのクエリに画像関連を追加 |
db/migrate/...create_active_storage_tables...rb |
active_storage_blobs , active_storage_attachments , active_storage_variant_records テーブルの作成 |
db/schema.rb |
Active Storage用の新しいテーブルの追加および外部キー制約の追加 |
db/seeds.rb |
ポスト作成時に特定のタイムスタンプを含むように変更 |
spec/rails_helper.rb |
ENV['RAILS_ENV'] 変数にデフォルト値 'test' を追加 |
spec/system/posts_spec.rb |
画像添付のテストを追加、ポスト詳細ページでの画像表示を確認するテストを追加 |
新しい風が吹くポストの地、
写真が添えられ、見た目も麗し。
Active Storageで保存し、
一目に分かる、この改良、
テストも通り、安心の未来。
さあ、投稿しよう、新しい彩り。
🌸📸✨
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Changes Lines
+98 additions, -12 deletions