groups_usersテーブル

Column Type Options
user_id integer null: false, foreign_key: true
group_id integer null: false, foreign_key: true

Association

  • belongs_to :group
  • belongs_to :user

groupsテーブル

Column Type Options
name string null: false

Association

  • has_many :users, though: :groups_users
  • has_many :messages
  • has_many :groups_users

usersテーブル

Column Type Options
email string null: false
password string null: false
name string null: false

Association

  • has_many :groups, though: :groups_users
  • has_many :messages
  • has_many :groups_users

messagesテーブル

Column Type Options
body text
image string
group_id integer null: false, foreign_key: true
user_id integer null: false, foreign_key: true

Association

  • belongs_to :user
  • belongs_to :group