diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index 02e74237a..82062d3dd 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -102,15 +102,14 @@ class OrgDocumentCommentsController < ApplicationController end def destroy - @org_document_comment = SubDocumentComment.find(params[:id]) - @sub_domain = @org_document_comment.sub_domain - @org_subfield = @sub_domain.org_subfield - # org = @org_document_comment.organization - # if @org_document_comment.id == org.home_id - # org.update_attributes(:home_id => nil) - # end - @org_document_comment.destroy - # end + @org_document_comment = OrgDocumentComment.find(params[:id]) + @org_sub_id = @org_document_comment.org_subfield_id + org = @org_document_comment.organization + if @org_document_comment.id == org.home_id + org.update_attributes(:home_id => nil) + end + if @org_document_comment.destroy + end respond_to do |format| format.js end diff --git a/app/controllers/sub_document_comments_controller.rb b/app/controllers/sub_document_comments_controller.rb index 767e1ba29..cdf153a20 100644 --- a/app/controllers/sub_document_comments_controller.rb +++ b/app/controllers/sub_document_comments_controller.rb @@ -125,6 +125,8 @@ class SubDocumentCommentsController < ApplicationController def destroy @sub_document_comment = SubDocumentComment.find(params[:id]) @sub_document_comment.destroy + @sub_domain = @sub_document_comment.sub_domain + @org_subfield = @sub_domain.org_subfield rescue ActiveRecord::RecordNotFound respond_to do |format| # format.html{ diff --git a/app/views/org_document_comments/destroy.js.erb b/app/views/org_document_comments/destroy.js.erb index 1e830d7bc..394078db1 100644 --- a/app/views/org_document_comments/destroy.js.erb +++ b/app/views/org_document_comments/destroy.js.erb @@ -1,6 +1,6 @@ //location.reload(); <% if params[:detail_page] %> - window.location.href = '<%= org_subfield_sub_domain_sub_document_comments_path(:org_subfield_id => @org_subfield.id, :sub_domain_id => @sub_domain.id)%>'; + window.location.href = '<%= organization_path(params[:organization_id],:org_subfield_id => @org_sub_id )%>'; <% else %> window.location.reload(); <% end %> \ No newline at end of file diff --git a/app/views/sub_document_comments/destroy.js.erb b/app/views/sub_document_comments/destroy.js.erb index 4a45e48dd..d4c7bffcd 100644 --- a/app/views/sub_document_comments/destroy.js.erb +++ b/app/views/sub_document_comments/destroy.js.erb @@ -1,6 +1,6 @@ //location.reload(); <% if params[:detail_page] %> -window.location.href = '<%= org_subfield_sub_domain_sub_document_comments_path(:org_subfield_id => @org_subfield.id, :sub_domain_id => @subdomain.id)%>'; +window.location.href = '<%= org_subfield_sub_domain_sub_document_comments_path(:org_subfield_id => @org_subfield.id, :sub_domain_id => @sub_domain.id)%>'; <% else %> window.location.reload(); <% end %> \ No newline at end of file diff --git a/app/views/sub_document_comments/show.html.erb b/app/views/sub_document_comments/show.html.erb index fc35d00cb..7050c1c66 100644 --- a/app/views/sub_document_comments/show.html.erb +++ b/app/views/sub_document_comments/show.html.erb @@ -56,7 +56,7 @@ <%= link_to "编辑文章", edit_org_subfield_sub_domain_sub_document_comment_path(@document, :org_subfield_id=> params[:org_subfield_id], :sub_domain_id => @document.sub_domain.id, :flag => 1), :class => "postOptionLink" %>