2016-10-24 3 views
0

정보를 표시하기 위해 ActiveAdmin 내에서 3 개의 has_many 관계로 이동합니다. 정보를 상위, 하위 형식으로 표시하려고합니다. 현재 이벤트가 있습니다. 이벤트 내에서 많은 위치가 있고, 각 위치에는 많은 날짜가 있으며, 각 날짜에는 많은 대사 (사용자)가 있습니다.하나 이상의 has_many 관계를 탐색하고 각각이 속한 콘텐츠를 표시합니다. Active Admin

정보가 표시되어 이벤트의 위치를 ​​확인한 다음 위치별로 날짜를 구분하고 날짜별로 구분 된 대사 (사용자)를 표시하고 싶습니다. 이것은 내가 현재 작성한 코드이지만 내가 찾고있는 부모 자식 디스플레이를 제공하지는 않습니다.

show do 

attributes_table do 
row :agency 
row :name 
row :event_details 
row :created_at 

panel "Locations" do 
    attributes_table_for event.event_locations do 
    row :label 
    row :address 
    row :zip 
    row :state 
    row :country 
    row :notes 
    panel "Event dates" do 
     event.event_locations.each do |r| 
     attributes_table_for r.event_dates do 
     row :event_date 
     panel "Ambassadors" do 
      attributes_table_for event.booking.booking_staff do 

       row :ambassador 

     end 
     end 

    end 
    end 
end 
    end 
end 
    end 
active_admin_comments end 

위의 코드에서 알 수 있듯이 나는 원하는 결과를 얻지 못할 것입니다. 어떤 제안이라도 대단히 감사하겠습니다. 감사.

답변

0

어쩌면 이것은 올바른 방향으로 당신을 가리킬 것입니다.

:attribute_of_event_date 

및 이와 유사한 기호를 데이터 (모델)의 컨텍스트에서 이해할 수 있도록 변경하십시오. 행운을 빕니다!

panel "Locations" do 
    resource.event_locations.each do |event_location| 

    attributes_table_for event_location do 
     row :label 
     row :address 
     row :zip 
     row :state 
     row :country 
     row :notes 

     panel "Event dates" do 
     event_location.event_dates.each do |event_date| 

      attributes_table_for event_date do 
      row :attribute_of_event_date 
      row :another_attribute_of_event_date 
      panel "Ambassadors" do 
       event_date.ambassadors.each do |ambassador| 

       attributes_table_for ambassador do 
        row :atttribute_of_ambassador 
        row :another_atttribute_of_ambassador 
       end 
       end 

      end 
      end 

     end 
     end 
    end 
    end 
end