私の状況はこんな感じです。会社には多くのユーザーがいて、ユーザーは多くの会社に所属している場合があります。そして、現在の実装は以下のようなものです。
class Company
has_many :employments
has_many :users, :through => :employments
end
class Employment
belongs_to :company
belongs_to :user
end
class User
has_many :employments
has_many :companies, :through => :employments #This doesn't looks correct
end
それは機能しますが、「ユーザーは多くの会社を持っています」は論理的に意味がありません。これは、belongs_to_many company のようなものに違いありません。has_and_belongs_to_many を使用する必要がありますか?
これらの関係を表す正しい方法を教えてください。