다형성 연결을 사용하려는 것처럼 들립니다. http://guides.rubyonrails.org/association_basics.html#polymorphic-associations
편집 계층 구조를 포함하는 업데이트 :
: 당신은 몇 가지 새로운 모델, 예를 들어 "수준"과 "어린이"를 필요로 같은
는 소리를 간단한 예를 들어 레일 가이드를 참조하십시오 그룹 모델 :
has_many :children, :as => :groupable
belongs_to :level
사람 모델 :
has_many :children, :as => :groupable
레벨 모델 :
has_many :children
has_one :group
attr_accessible :level (integer)
어린이 모델 :
belongs_to :groupable, :polymorphic => true
아이들과 수준 모델을 결합하여이 문제를 단순화 할 수도 있지만 액티브 두 관계를 처리 할 수 있는지 모르겠어요 두 개의 테이블 사이 (그룹 또는 사람들 인 어린이 그룹을위한 그룹과 부모 그룹을위한 그룹).
계층 구조 레벨은에 반영됩니다.레벨 모델의 정수.
class Group < AR::Base
acts_as_tree # or whatever is called in your preferred tree implementation
has_many :users
end
class User < AR::Base
belongs_to :group
end
당신은해야합니다 :
그래서'그룹'은 다형성 관련 열을 포함할까요? 또한, 어떻게이 계층 구조를 얻을 수 있습니까? – RailinginDFW