0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

中間テーブルとは

・多対多の関係性があるテーブルの間に設置するテーブル
・接続する2テーブルの外部キーをもつ

分かりやすい記事↓
https://qiita.com/ramuneru/items/db43589551dd0c00fef9

注意

テーブル間にアソシエーションを書く時、
例)usersテーブル、tagsテーブル、tweetsテーブルがある時、

Userモデルには
has_many :user_tweets
has_many :tweets, through: :user-tweets
の順番でかく。
has_many throughで経由するテーブルとのアソシエーションを先に記載しないとエラーになる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?