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:
Thomas Wood 2009-01-23 19:14:21 +00:00
parent 9bb9de0fbe
commit 1522ed275c

View file

@ -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