solve extension probelm

This commit is contained in:
yqbk
2016-08-03 17:21:49 +02:00
parent 605f64395f
commit 41b0c1e530
3 changed files with 2 additions and 88 deletions

View File

@ -27,8 +27,7 @@ module CodeOcean
path = options[:path].try(:call) || @object
respond_with_valid_object(format, notice: t('shared.object_created', model: @object.class.model_name.human), path: path, status: :created)
else
# I have deleted ".file_extension" due to error "undefined method `file_extension' for nil:NilClass"
filename = (@object.path || '') + '/' + (@object.name || '') + (@object.file_type.file_extension || '')
filename = (@object.path || '') + '/' + (@object.name || '') + (@object.file_type.try(:file_extension) || '')
format.html { redirect_to(options[:path]); flash[:danger] = t('files.error.filename', name: filename) }
format.json { render(json: @object.errors, status: :unprocessable_entity) }
end