Set params to sane defaults if unset by client.
Reject creates with no file with 400, model validations will also reject with 400 (as was existing but broken behaviour) Closes #1510
This commit is contained in:
parent
9bb9de0fbe
commit
1522ed275c
1 changed files with 13 additions and 5 deletions
|
@ -279,12 +279,20 @@ class TraceController < ApplicationController
|
|||
|
||||
def api_create
|
||||
if request.post?
|
||||
do_create(params[:file], params[:tags], params[:description], params[:public])
|
||||
tags = params[:tags] || ""
|
||||
description = params[:description] || ""
|
||||
pub = params[:public] || false
|
||||
|
||||
if params[:file].respond_to?(:read)
|
||||
do_create(params[:file], tags, description, pub)
|
||||
|
||||
if @trace.id
|
||||
render :text => @trace.id.to_s, :content_type => "text/plain"
|
||||
elsif @trace.valid?
|
||||
render :nothing => true, :status => :internal_server_error
|
||||
if @trace.id
|
||||
render :text => @trace.id.to_s, :content_type => "text/plain"
|
||||
elsif @trace.valid?
|
||||
render :nothing => true, :status => :internal_server_error
|
||||
else
|
||||
render :nothing => true, :status => :bad_request
|
||||
end
|
||||
else
|
||||
render :nothing => true, :status => :bad_request
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue