2つのモデルがあり、それぞれが別のモデルに依存しています。別のレコードに依存してレコードを作成する方法
class Company < ActiveRecord
belongs_to :user
end
class User < ActiveRecord
belongs_to :company
end
会社には必須のuser_id列があります。 ユーザーには必須のcompany_id列があります。
企業とユーザーの両方が互いに依存している場合、どのように作成できますか?この関係がmany to many relationship
と呼ばれ、あなたのscenarionで
私は結合テーブルはcompanies_users、両方の複数でなければならないと思います。アルファベット順。 http://guides.rubyonrails.org/association_basics.html#creating-join-tables-for-has_and_belongs_to_many-associations –