2016-08-03 3 views
1

내가 인덱스 page.I에서 고객의 세부 목록을 표시해야레일 둥지

가 중첩 된 형태 또한 필드가 나열 될 '제품은 해결'할 index.html.haml 인덱스 페이지에서 부모 폼과 양식을 중첩 할 수 없습니다 인덱스 페이지에

%tbody 
 
     - @customer_details.each do |customer| 
 
      %tr 
 
      %td= customer.customer_name 
 
      %td= customer.customer_id 
 
      %td= customer.address 
 
      %td= customer.state 
 
      %td= customer.email 
 
       - customer.goods_address.each do |goods_address| 
 
       %td= goods_address.delivery_address 
 
       %td= goods_address.name 
 
       %td= goods_address.address 
 
       %td= goods_address.state
문제는 제품의 주소를 '각'을 정의되지 않은 메서드를 받고 메신저입니다. 이 문제를 해결하는 방법을 모른다. 누군가가 사전에 찾아 와요 고마워요 도움이 될 수 있습니다 것은

답변

0

고객 중 일부는 goods_address 그래서 eachnil obect에서 수행 할 수 없습니다 수 있습니다

시도 :

%tbody 
    - @customer_details.each do |customer| 
    %tr 
     %td= customer.customer_name 
     %td= customer.customer_id 
     %td= customer.address 
     %td= customer.state 
     %td= customer.email 
     - if customer.goods_address.present? 
      %td= customer.goods_address.delivery_address 
      %td= customer.goods_address.name 
      %td= customer.goods_address.address 
      %td= customer.goods_address.state 
+0

내가 정의되지 않은 메서드 같은 오류가 그렇진 # 에 대한 'each' –

+0

@HariPrakash : 귀하의 질문에 귀하의 협회를 업데이트 할 수 있습니까? –

+0

클래스 CustomerDetail