修复附件编辑的时候偶尔不成功的问题
This commit is contained in:
parent
4477223637
commit
b89b778872
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue