From 925aae4f01ea1f8c1fc112f5bf5971e4689b4233 Mon Sep 17 00:00:00 2001 From: Saurabh Bhatia Date: Wed, 19 Feb 2014 15:16:58 +0800 Subject: [PATCH] converted to render json --- app/controllers/api/v1/clients_controller.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/v1/clients_controller.rb b/app/controllers/api/v1/clients_controller.rb index a9ef6fe..72644d9 100644 --- a/app/controllers/api/v1/clients_controller.rb +++ b/app/controllers/api/v1/clients_controller.rb @@ -4,8 +4,12 @@ module Api respond_to :json def create - @client = Client.create(client_params) - respond_with(@client,status: :created) rescue error(409) + @client = Client.new(client_params) + if @client.save + render :json => @client + else + render :json => { :errors => @client.errors.full_messages , :status => 422}.to_json + end end private