如果没有上传图片就会报空指针
This commit is contained in:
parent
0424fc55db
commit
a4567396e4
|
@ -26,10 +26,12 @@ class DiscussDemosController < ApplicationController
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
asset = Kindeditor::Asset.find_by_owner_id(params[:id])
|
asset = Kindeditor::Asset.find_by_owner_id(params[:id])
|
||||||
|
if !asset.nil?
|
||||||
filepath = File.join(Rails.root,"public","files","uploads",
|
filepath = File.join(Rails.root,"public","files","uploads",
|
||||||
asset[:created_at].to_s.gsub("+0800","").to_datetime.strftime("%Y%m").to_s,
|
asset[:created_at].to_s.gsub("+0800","").to_datetime.strftime("%Y%m").to_s,
|
||||||
asset[:asset].to_s)
|
asset[:asset].to_s)
|
||||||
File.delete(filepath) if File.exist?filepath
|
File.delete(filepath) if File.exist?filepath
|
||||||
|
end
|
||||||
DiscussDemo.destroy(params[:id])
|
DiscussDemo.destroy(params[:id])
|
||||||
redirect_to :controller=> 'discuss_demos',:action => 'index'
|
redirect_to :controller=> 'discuss_demos',:action => 'index'
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue