diff --git a/app/controllers/discuss_demos_controller.rb b/app/controllers/discuss_demos_controller.rb index a0955efe2..b0c9791cb 100644 --- a/app/controllers/discuss_demos_controller.rb +++ b/app/controllers/discuss_demos_controller.rb @@ -26,10 +26,12 @@ class DiscussDemosController < ApplicationController def destroy asset = Kindeditor::Asset.find_by_owner_id(params[:id]) - filepath = File.join(Rails.root,"public","files","uploads", - asset[:created_at].to_s.gsub("+0800","").to_datetime.strftime("%Y%m").to_s, - asset[:asset].to_s) - File.delete(filepath) if File.exist?filepath + if !asset.nil? + filepath = File.join(Rails.root,"public","files","uploads", + asset[:created_at].to_s.gsub("+0800","").to_datetime.strftime("%Y%m").to_s, + asset[:asset].to_s) + File.delete(filepath) if File.exist?filepath + end DiscussDemo.destroy(params[:id]) redirect_to :controller=> 'discuss_demos',:action => 'index' end