저는 Rails 2와 함께 Agile Web Development에 문제가있는 초보자입니다. Ruby verison 1.8.6. 책이 admin_controller.rb에 스캐 폴드 제품을 넣도록 지시했을 때 문제가 시작되었습니다. 선을 제거했는데 이제 다음과 같은 오류 메시지가 나타납니다. 라인 # 10 제기 관리자/index.html.erb을 표시 관리자 # 지수 에서NoMethodError in Admin # 색인
NoMethodError : 당신이 그것을 기대하지 않았을 때
당신은 전무 개체가 있습니다! Array의 인스턴스를 예상했을 수 있습니다.
여기 컨트롤러 /InstantRails-2.0-win/rails_apps/depot :
7: <th>Image url</th>
8: </tr>
9:
10: <% for product in @product %>
11: <tr>
12: <td><%=h product.title %></td>
13: <td><%=h product.description %></td>
RAILS_ROOT : C (라인 # 10 정도) nil.each
추출 소스를 평가하면서 오류가 발생한 정보 : admin_controller 클래스 AdminController <와 ApplicationController 끝 여기
뷰 정보입니다 : 조회수 \ 관리자 \의 index.html.erb
목록 제품
<table>
<tr>
<th>Title</th>
<th>Description</th>
<th>Image url</th>
</tr>
<% for product in @product %>
<tr>
<td><%=h product.title %></td>
<td><%=h product.description %></td>
<td><%=h product.image_url %></td>
<td><%= link_to 'Show', product %></td>
<td><%= link_to 'Edit', edit_product_path(product) %></td>
<td><%= link_to 'Destroy', product, :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New product', new_product_path %>
다음 모델 정보의
: 모델 \ product.rb 일류 상품 < 액티브 :: 자료 끝어떤 조언을?
관리자 용 컨트롤러의 모양은 어떻습니까? 색인 작업이 있습니까? 그 안에'@ product'를 설정하고 있습니까? – MrDanA
관리자 컨트롤러가 비어 있습니다. 책은 나에게 오류 메시지를 준 제품인 비계를 제안했습니다. 여기에 현재의 컨트롤러가 있습니다. class AdminController
yatta20