DB練習の開発コード
テーブル名
カラム名
カラムの型
カラムのオプション(null false制約など)
アソシエーション
Column |
Type |
Options |
name |
string |
null: false |
email |
string |
null: false |
password |
string |
null: false |
- has_many :room_users
- has_many :rooms, through: room_users
- has_many :messages
Column |
Type |
Options |
name |
string |
null: false |
- has_many :room_users
- has_many :users, through: room_users
- has_many :messages
Column |
Type |
Options |
user |
references |
null: false, foreign_key: true |
room |
references |
null: false, foreign_key: true |
- belongs_to :room
- belongs_to :user
Column |
Type |
Options |
content |
string |
|
user |
references |
null: false, foreign_key: true |
room |
references |
null: false, foreign_key: true |
- belongs_to :room
- belongs_to :user
チャットルームを作成。
ユーザーはどこのルームにも行けてメッセージも画像も投稿できる。