app/controllers/admin/sheet_resource_controller.rb in radiant-sheets-extension-1.0.10 vs app/controllers/admin/sheet_resource_controller.rb in radiant-sheets-extension-1.0.11
- old
+ new
@@ -7,11 +7,17 @@
def upload
if params[:upload].blank? # necessary params are missing
render :text => '', :status => :bad_request
else
- @sheet = model_class.create_from_upload!(params[:upload][:upload])
- response_for :create
+ @sheet = model_class.create_or_update_from_upload!(params[:upload][:upload])
+ if @sheet.new_record?
+ response_for :create
+ else
+ slug = params[:upload][:upload].original_filename.to_slug().gsub(/-dot-css$/,'.css').gsub(/-js/,'.js')
+ flash[:notice] = "#{slug} was succesfully overwritten."
+ response_for :update
+ end
end
end
def new
self.model = model_class.new_with_defaults