Skip to content
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

DB設計 #13

Open
Tomohiro-Yamamoto201 opened this issue Oct 19, 2020 · 0 comments
Open

DB設計 #13

Tomohiro-Yamamoto201 opened this issue Oct 19, 2020 · 0 comments

Comments

@Tomohiro-Yamamoto201
Copy link
Owner

Tomohiro-Yamamoto201 commented Oct 19, 2020

DB設計

Users TB

Column Type Options
id integer ---
nickname string null: false
email string null: false, unique: true
gender integer null: false
height integer null: false
body_weight integer null: false
born_on date ---
  • has_many : training_menus
  • has_many : training_reports
  • has_many : likes
  • has_many :liked_training_reports, through: :likes, source: :training_report

ユーザー情報のルーティング

HTTP動詞 パス コントローラー#アクション 目的
GET /users users#index すべてのユーザー一覧、筋トレ情報を表示
GET /users/new users#new ユーザーアカウントを新規作成するためのHTMLフォームを返す
POST /users users#create ユーザーアカウントを作成する
GET /users/:id users#show マイページを表示する。筋トレ予定登録、筋トレ報告ページにそれぞれ進むことができる。
GET /users/:id/edit users#edit ユーザー情報編集用のHTMLフォームを1つ返す
PATCH/PUT /users/:id users#update ユーザー情報を更新する
DELETE /users/:id users#destroy ユーザー情報を削除する

TrainingMenus TB

メニューのタイトルを入力する。

Column Type Options
id integer ---
training_menu string null: false
published_at datetime ---
user_id references null: false, index: true, foreign_key: true
  • belongs_to : user
  • has_many : trainings

Trainings TB

筋トレ内容とスケジュールを入力する

Column Type Options
id integer ---
training_category string null: false
training_name string null: false
training_menu_id references null: false, index: true, foreign_key: true
growing_parts string null: false
  • belongs_to : training_menu

TrainingReports TB

掲示板に投稿する内容を入力する

Column Type Options
id integer ---
content text null: false
user_id references null: false, index: true, foreign_key: true
  • belongs_to : user
  • has_many : likes
  • liked_users, through: :likes, source: :user

筋トレ投稿のルーティング

HTTP動詞 パス コントローラー#アクション 目的
GET /training_reports training_reports#index ログイン前:ログインへのリンク ログイン後:投稿一覧を表示、投稿ができる
GET /training_reports/:id training_reports#show ・投稿の詳細・「いいね」ができる・投稿に「いいね」したユーザー一覧表示
DELETE /training_reports/:id training_reports#destroy 投稿を削除する

Likes TB

ユーザーの投稿に「いいね」する

Column Type Options
id integer ---
user_id references null: false, index: true, foreign_key: true
training_report_id references null: false, index: true, foreign_key: true
  • belongs_to : user
  • belongs_to : training_report
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

No branches or pull requests

1 participant