2016-10-24 6 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 
関連する問題