Closed Shuma-Yamamoto closed 2 years ago
大学モデル university ・大学名 name (string) ・学部名 faculty (string) ・学科名 department (string) ・偏差値 score (float) ・メールアドレス email (string) ・パスナビurl url (text)
都道府県モデル prefecture ・都道府県名 name (string)
高校モデル high_school ・高校名 name (string) ・偏差値 score (float) ・パスナビurl url (text) ・都道府県コード (FK)
塾モデル cram_school ・塾名 name (string)
模試モデル mock_exam ・模試名 name (string)
科目モデル subject ・科目名 name (string)
参考書モデル book ・参考書名 name (string) ・価格 price (integer) ・Amazon-url url (text) ・科目コード (FK)
受験生モデル examinee ・ユーザ名 name (string) ・メールアドレス email (string) ・パスワード password (string) ・学年 grade (integer /enum)
大学生モデル university_student ・ユーザ名 name (string) ・メールアドレス email (string) ・パスワード password (string) ・入学年度 entrance_at (integer) ・浪人年数 ronin (integer) ・出身高校公開可否 anonymous_high_school (boolean) ・入部時期 join_club_at (date) ・退部/引退時期 leave_club_at (date) ・部活動頻度 club_frequency (integer) ・大学コード (FK) ・高校コード (FK)
参考書修正モデル fix_book ・修正詳細 detail (text) ・大学生ID (FK) ・参考書ID (FK)
受験科目モデル exam_subject ・大学生ID (FK) ・科目コード (FK)
レビューモデル review ・開始時期 begin_about (integer /enum) ・開始季節 begin_season (integer /enum) ・開始月 begin_month (integer) ・終了時期 finish_about (integer /enum) ・終了季節 finish_season (integer /enum) ・終了月 finish_month (integer) ・開始時偏差値 beginning_score (float) ・長所 pro (text) ・短所 con (text) ・おすすめの人 recommended_person (text) ・おすすめの使い方 recommended_usage (text) ・総合評価 evaluation (integer) ・大学生ID (FK) ・参考書ID (FK) ・模試コード (FK)
お気に入りレビューモデル favorite_review ・受験生ID (FK) ・レビューID (FK)
お気に入り参考書モデル favorite_book ・受験生ID (FK) ・参考書ID (FK)
通塾履歴モデル cram_history ・入塾時期 join_at (date) ・退塾/卒塾時期 leave_at (date) ・大学生ID (FK) ・塾コード (FK)
Rails 命名規則 https://www.y-hakopro.com/entry/2019/06/25/235943
モデルの作成 https://www.sejuku.net/blog/26974
マイグレーションファイルの書き方 https://yumanoblog.com/rails-migrationfile/
マイグレーションファイル 制約の書き方 https://qiita.com/kenji-nishie/items/0e37cd7b2459a7a31cfb
モデルファイル アソシエーションの書き方 リンク
モデルファイル バリデーションの書き方 https://qiita.com/h1kita/items/772b81a1cc066e67930e
中間テーブルの作成 https://qiita.com/Kohei_Kishimoto0214/items/cb9a3d3da57708fb52c9
deviseの使い方 https://qiita.com/cigalecigales/items/16ce0a9a7e79b9c3974e
deviseで作成したモデルにカラムを追加 https://www.techpit.jp/courses/3/curriculums/4/sections/26/parts/85
deviseで作成したモデルに外部キーを追加 https://qiita.com/kurawo___D/items/e3694f7a870a1cc4738e →このやり方じゃなくて普通にaddじゃない方のmigrationファイルにいつも通り記述すれば良くね?
deviseの複数使用 https://qiita.com/AKI3/items/09f7de4abb6b4a34cde3
deviseでメールアドレス認証 https://qiita.com/ozackiee/items/21fcad4a1564136b9510
rails g model は外部キーがないやつから順に作成していく。 外部キーのあるやつを先に作成しちゃうと時系列がおかしくなっちゃうから。
大学の学科名は存在しない場合もあるのでnull制約は付けなかった。 高校の偏差値はBFの場合もあるのでnull制約は付けなかった。 大学生の入部時期は部活に入っていない場合もあるのでnull制約は付けなかった。 大学生の退部/引退時期は部活に入っていない場合もあるのでnull制約は付けなかった。 大学生の部活動頻度は部活に入っていない場合もあるのでnull制約は付けなかった。
テーブルから生えている足の数だけbelongs_to, has_manyがあるかどうか(モデルファイル) belongs_toの数だけt.referencesがあるかどうか(マイグレーションファイル) null: falseをnull: trueと間違えていないか(Ctrl + Fで確認)
完了要件
大学モデル
マイグレーションファイル
reference
)モデルファイル
has_many
,belongs_to
)都道府県モデル
マイグレーションファイル
reference
)モデルファイル
has_many
,belongs_to
)高校モデル
マイグレーションファイル
reference
)モデルファイル
has_many
,belongs_to
)塾モデル
マイグレーションファイル
reference
)モデルファイル
has_many
,belongs_to
)模試モデル
マイグレーションファイル
reference
)モデルファイル
has_many
,belongs_to
)科目モデル
マイグレーションファイル
reference
)モデルファイル
has_many
,belongs_to
)参考書モデル
マイグレーションファイル
reference
)モデルファイル
has_many
,belongs_to
)受験生モデル
マイグレーションファイル
reference
)モデルファイル
has_many
,belongs_to
)大学生モデル
マイグレーションファイル
reference
)モデルファイル
has_many
,belongs_to
)参考書修正モデル
マイグレーションファイル
reference
)モデルファイル
has_many
,belongs_to
)受験科目モデル
マイグレーションファイル
reference
)モデルファイル
has_many
,belongs_to
)レビューモデル
マイグレーションファイル
reference
)モデルファイル
has_many
,belongs_to
)お気に入りレビューモデル
マイグレーションファイル
reference
)モデルファイル
has_many
,belongs_to
)お気に入り参考書モデル
マイグレーションファイル
reference
)モデルファイル
has_many
,belongs_to
)通塾履歴モデル
マイグレーションファイル
reference
)モデルファイル
has_many
,belongs_to
)