jeudi 30 avril 2020

How to write factories for models with has many through association?

I have three models with has many through association User model class User < ActiveRecord::Base has_many :user_projects has_many :projects, through: :user_projects end

Project model

class Project < ActiveRecord::Base has_many :user_projects has_many :users, through: :user_projects end

UserProject model class UserProject < ActiveRecord::Base belongs_to :user belongs_to :project end

How to create factories for these three models

Aucun commentaire:

Enregistrer un commentaire