From 76006ef3e71b1c66ec2c124b9d02ef032931acbd Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Fri, 20 May 2016 22:07:33 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=84=E7=BB=87=E4=B8=80=E7=BA=A7=E4=BA=8C?= =?UTF-8?q?=E7=BA=A7=E5=B8=96=E5=AD=90=E5=88=A0=E9=99=A4=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org_document_comments_controller.rb | 17 ++++++++--------- .../sub_document_comments_controller.rb | 2 ++ app/views/org_document_comments/destroy.js.erb | 2 +- app/views/sub_document_comments/destroy.js.erb | 2 +- app/views/sub_document_comments/show.html.erb | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) 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" %>
  • - <%= link_to "删除文章", org_document_comment_path(:id => @document.id, :organization_id => @organization.id, :detail_page => 1), :method => 'delete', + <%= link_to "删除文章", org_subfield_sub_domain_sub_document_comment_path(@document, :org_subfield_id=> params[:org_subfield_id], :sub_domain_id => @document.sub_domain.id, :flag => 0, :detail_page=>1), :method => 'delete', :data => {:confirm => l(:text_are_you_sure)}, :remote => true, :class => 'postOptionLink' %>