修复附件编辑的时候偶尔不成功的问题

This commit is contained in:
huang 2018-02-09 15:03:28 +08:00
parent 4477223637
commit b89b778872
1 changed files with 10 additions and 2 deletions

View File

@ -83,10 +83,17 @@ class StatisticsController < ApplicationController
# PUT /statistics/1.json
def update
@statistic = Statistic.find(params[:id])
respond_to do |format|
if @statistic.update_attributes(params[:statistic])
@statistic.save_attachments_containers(params[:attachments], User.current, true)
# @statistic.save_attachments_containers(params[:attachments], User.current, true)
params[:attachments].each_value do |attachment|
temp_attachment = Attachment.where(:id => attachment['attachment_id']).first
if temp_attachment.present? && temp_attachment.container_id.blank?
temp_attachment.update_attributes(:container_id => @statistic.id, :container_type => "Statistic")
end
end
# @issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads]))
format.html { redirect_to @statistic, notice: 'Statistic was successfully updated.' }
format.json { head :no_content }
else
@ -125,4 +132,5 @@ class StatisticsController < ApplicationController
@main_categories = MainCategory.all
@sub_categories = params[:main_category_id].present? ? SubCategory.where(:main_category_id => params[:main_category_id]) : SubCategory.all
end
end