0
내 RoR에 응용 프로그램에서 다음과 같은 오류가 점점 오전
: RJS 오류 :비정상적인 RJS 오류
형식 오류 : 요소 ("통지", "코멘트 게시 됨") 널 (null)
Element.update이다; Element.update ("allcomments", "\ n \ n \ n \ n \ n 지금 알려주십시오. \ n \ n \ n \ n \ n \ n \ n \ n asdfasdfa \ n \ n \ n \ n \ n asdfasdf \ n \ n \ n \ n \ n \ n
\ n ");
하지만 새로 고침 버튼을 누르면 부분 업데이트 된 것을 볼 수 있습니다.
show_comments보기 :
<table>
<% comments.each do |my_comment| %>
<tr>
<td><%=h my_comment.comment%></td>
</tr>
<% end %>
</table>
쇼보기 :
<div class="wrapper">
<div class="rescale">
<div class="img-main">
<%= image_tag @deal.photo.url %>
</div>
</div>
<div class="description">
<p class ="description_content">
<%=h @deal.description %>
</p>
</div>
</div>
<p>
<b>Category:</b>
<%=h @deal.category %>
</p>
<p>
<b>Base price:</b>
<%=h @deal.base_price %>
</p>
<%#*<p>%>
<%#*<b>Discount:</b>%>
<%#=h @deal.discount %>
<%#*</p>%>
<%= link_to 'Edit', edit_deal_path(@deal) %> |
<%= link_to 'Back', deals_path %>
<p>
<%= render :partial=>'deal_comments', :locals=>{
:comments=>Comment.new(:deal_id=>@deal.id)} %>
</p>
<div id="allcomments">
<%= render :partial=>'show_comments', :locals=>{
:comments=>Comment.find(@deal.comments)} %>
</div>
컨트롤러 :
def create
@comment = Comment.new(params[:comment])
render :update do |page|
if @comment.save
page.replace_html 'notice', 'Comment Posted'
else
page.replace_html 'notice', 'Something went wrong'
end
page.replace_html 'allcomments', :partial=> 'deals/show_comments',
:locals=>{:comments=> @comment.deal.comments}
end
end
def show_comments
@deal = Deal.find(params[:deal_id])
render :partial=> "deals/show_comments", :locals=>{:comments=>@deal.comments}
end
end
아, 감사합니다. 많은 스테이크! 나는 내 레이아웃보기에서 그 부분을 주석 처리했으며 주석을 해제하는 것을 잊었습니다. – rb512
@rrn 인 경우 이전 질문을 확인하여 해결해야합니다. 그것은 저자에게 좋은 보복이 될 것입니다 ... – apneadiving