0
Vehicle이라는 모델이 있습니다. 차량의 부모가 레일 콘솔을 통해 무엇을 찾는 지 어떻게 알 수 있습니까? 예 :레일스 콘솔이 모델의 부모를 찾았다면
vehicle = Vehicle.find(1)
vehicle.parent
vehicle.parent_id.present?
Vehicle이라는 모델이 있습니다. 차량의 부모가 레일 콘솔을 통해 무엇을 찾는 지 어떻게 알 수 있습니까? 예 :레일스 콘솔이 모델의 부모를 찾았다면
vehicle = Vehicle.find(1)
vehicle.parent
vehicle.parent_id.present?
"parent"는 인스턴스가 아닌 클래스 전용입니다. 그래서, 클래스의 부모 뜻 경우
vehicle.class.parent
에 대한 협회 대신 클래스의는 reflections
vehicle.reflections
은 무엇 관계 (belongs_to, has_many가)처럼 보이나요 사용할 수 있습니까? – pduersteler