-
카테고리
-
세부 분야
프로그래밍 언어
-
해결 여부
미해결
@POST.DESTROY 질문이 있습니다
20.12.09 18:32 작성 조회수 147
0
CONTROLLER에서
def delete
@post = Post.find(params[:id])
@post.destroy
render :index
end
def index
@posts = Post.all
end
위와 같이 delete 이후 전체 글목록을 불러오는
index로 render를 해주었습니다.
그랬더니
% @posts.each do |t| %>
이 부분에서 오류가 나버립니다.
오류 내용은 아래와 같습니다
ActionView::Template::Error (undefined method `each' for nil:NilClass):
갑자기 each에서 왜 오류가 나는지 모르겠습니다.
삭제 후에만 오류가 납니다.
답변을 작성해보세요.
1
답변 1