チーム共有用
機能洗い出し
- ユーザー新規登録/ログイン・ログアウト
- 商品出品・購入
- コメント
- カテゴリー検索
- マイページ/商品編集機能
- クレジットカード登録・変更
ER図
DB設計
usersテーブル
| Column | Type | Options |
|---|---|---|
| nickname | string | null: false |
| string | null: false, unique: true | |
| password | string | null: false |
| family_name | string | null: false |
| first_name | string | null: false |
| family_name_kana | string | null: false |
| first_name_kana | string | null: false |
| birthday_year | string | null: false |
| birthday_month | string | null: false |
| birthday_day | string | null: false |
Association
- belongs_to :delivery_date dependent: :destroy
- has_many :creditcards dependent: :destroy
- has_many :comennts dependent: :destroy
- has_many :products dependent: :destroy
delivery_datasテーブル
| Column | Type | Options |
|---|---|---|
| family_name | string | null: false |
| first_name | string | null: false |
| family_name_kana | string | null: false |
| first_name_kana | string | null: false |
| zipcode | integer | null: false |
| prefecture | string | null: false |
| city | string | null: false |
| address | string | null: false |
| building | integer | |
| phone | integer | |
| user | reference | null: false, foreign_key: true |
Association
- belongs_to :user
productsテーブル
| Column | Type | Options |
|---|---|---|
| name | string | null: false |
| comment | text | null: false |
| price | integer | null: false |
| brand | string | |
| size | string | |
| shippingcharge | string | null: false |
| area | string | null: false |
| days | string | null: false |
| user | reference | null: false, foreign_key: true |
| category | reference | null: false, foreign_key: true |
Association
- belongs_to :user dependent: :destroy
- belongs_to :category dependent: :destroy
- has_many :comments dependent: :destroy
- has_many :images dependent: :destroy
categorysテーブル
| Column | Type | Options |
|---|---|---|
| name | string | null: false |
Association
- has_many :products
commentsテーブル
| Column | Type | Options |
|---|---|---|
| content | text | |
| user | reference | null: false, foreign_key: true |
| product | reference | null: false, foreign_key: true |
Association
- belongs_to :user
- belongs_to :product
creditcardsテーブル
| Column | Type | Options |
|---|---|---|
| user | reference | null: false, foreign_key: true |
| customer | string | null: false |
| card | string | null: false |
Association
- belongs_to :user
imagesテーブル
| Column | Type | Options |
|---|---|---|
| image | image | null: false |
| product | reference | null: false, foreign_key: true |
Association
- belongs_to :product
補足
-
payjp公式リファレンス
https://pay.jp/docs/api/#charge%E3%82%AA%E3%83%96%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88
creditcardテーブル
user_id:userテーブルのid
customer_id:顧客ID/一度の登録で複数回使用できるようにする。
card_id:customerを使用している場合、card_idを指定する事でデフォルトカード以外のカードも使用できる -
アソシエーションのdependentオプション
https://pikawaka.com/rails/association#dependent%E3%82%AA%E3%83%97%E3%82%B7%E3%83%A7%E3%83%B3
親レコードが削除された時に子レコードデータとの整合性を保つ事ができる。