0
활성 관리자를 사용하는 레일 애플리케이션이 있습니다. 우리가 세 개의 엔티티를 가지고 있다고 가정 해 봅시다.활성 관리자 관련 중첩 입력
학생 :
has_many :activities, :through => :student_activities
has_and_belongs_to_many :teams
활동 :
has_many :teams, :dependent => :destroy
팀 :
이belongs_to :activity
has_and_belongs_to_many :students
그래서 활성 관리자 입력 양식의 student.rb에, 나는 학생이 활동을 선택하려면 그것에 팀 :
form do |f|
f.inputs do
f.input :name
end
if object.new_record?
f.has_many :student_activities, allow_destroy: true do |ff|
ff.input :activity ,:input_html_options => { :class => 'chosen' }
ff.input :team ,:input_html_options => { :class => 'chosen' }
end
end
f.actions
end
제 문제는이 코드가 모든 팀을 표시한다는 것입니다. 선택한 활동에 대한 팀 목록이 아닙니다.
그래서 팀원들만 활동을 보여줄 수 있습니까? 그가 선택한 활동에 따라 : 활동, 그리고 그가 아직 활동을 선택하지 않은 경우, 그에게 빈 목록을 보여줍니다.