class Post has_many :post_users has_many :users, through: :post_users end class PostUser belongs_to :post belongs_to :user end class User has_many :post_users has_many :posts, through: :post_users end