2012-12-05 3 views
0

enter image description here중첩 리소스 슬픈 경로 빈 설명 렌더링

게시물 리소스에 중첩 된 의견 리소스가 있습니다.

def create 
    @post = Post.find(params[:post_id]) 
    @comment = @post.comments.build(params[:comment]) 
    @comment.ip = request.remote_ip 
    if @comment.save 
     redirect_to post_path(@post, notice: "Comment was successfully created") 
    else 
     flash[:alert] = "Comment could not be created" 
     render 'posts/show' 
    end 
    end 

이 모두 충분히 잘 작동하지만이 점에서 자성 항목이있을 때 주석 양식 게시물/쇼 페이지를 다시 렌더링이 검증 인라인을 통과하지 못한 주석을 보여줍니다. 이 작업을 수행하는 올바른 방법을 알고 싶습니다. 뷰 계층에서 일부 논리를 수행하지 않아서 저장되지 않은 주석이 표시되지 않습니다. 나는 다른 해결책을 찾을 수 없기 때문에

답변

0

는 내가보기에 그것을 해결 결국

<% @post.comments.each do |c| %> 
    <% unless c.new_record? %> 
    <strong><%= "#{c.name} wrote: " %></strong><br /> 
    <blockquote><%= c.body %></blockquote> 
    <% end %> 
<% end %>