다음 인스턴스에서 Chlid 클래스의 belongs_to : mother 및 has_one : mother 사용의 차이점은 무엇입니까? 나는 이것에 대한 Rails 문서를 읽었으며, 어느 것이 든 그것을 읽는 것과 관련된 의미와 다른 점을 알 수는 없다.ruby on Rails belongs_to 대 has_one 연관 - 명확화 요청
다양한 연결에서 각 클래스에 추가 메서드를 추가하지만 연관성을 나열하는 문서를 메서드가 무엇인지, 무엇을하고 있는지 찾을 수 없었습니다.
class BiologicalMother < ActiveRecord::Base
has_many :children
end
class Child < ActiveRecord::Base
belongs_to :biological_mother
end
"belongs_to 및 has_one 선택"에 대한 공식 문서는 다음과 같습니다. http://guides.rubyonrails.org/association_basics.html#choosing-between-belongs-to-and-has-one 그것은 다음과 같습니다. 구별은 외래 키를 놓는 위치입니다 (belongs_to 연관을 선언하는 클래스의 테이블에 있습니다). " –