如果没有上传图片就会报空指针
This commit is contained in:
parent
0424fc55db
commit
a4567396e4
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue