iyuichiの私的開発ログ

渋谷で働くWebエンジニアのログ. Java, Android, iOS, Docker, GCP, AWS, ゲーム開発

多対多関連には、has_many :through

モデルクラスに"has_many :through"を記述することで中間テーブルを意識しないで関連テーブルを扱えるとか。

class Entry < ActiveRecord::Base
  has_many :中間テーブル
  has_many :関連テーブル, :through=>:中間テーブル
end