나는 두 모델을 가지고 있는데, 각각은 서로 의존한다.다른 레코드에 의존 할 때 레코드를 만드는 방법
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 –