
エントリーの編集

エントリーの編集は全ユーザーに共通の機能です。
必ずガイドラインを一読の上ご利用ください。
has_manyで中間テーブルから親モデルの別のassociationを取ってきたい - Qiita
記事へのコメント0件
- 注目コメント
- 新着コメント
このエントリーにコメントしてみましょう。
注目コメント算出アルゴリズムの一部にLINEヤフー株式会社の「建設的コメント順位付けモデルAPI」を使用しています

- バナー広告なし
- ミュート機能あり
- ダークモード搭載
関連記事
has_manyで中間テーブルから親モデルの別のassociationを取ってきたい - Qiita
class User < ApplicationRecord has_many :group_users has_many :groups, through: :group_users has_... class User < ApplicationRecord has_many :group_users has_many :groups, through: :group_users has_many :comments end class Group < ApplicationRecord has_many :group_users has_many :users, through: :group_users has_many :comments end class Comment < ApplicationRecord belongs_to :user belongs_to :group end class GroupUser < ApplicationRecord belongs_to :group belongs_to :user end このようなクラスが存在しているとします。