converted to render json

This commit is contained in:
Saurabh Bhatia 2014-02-19 15:16:58 +08:00
parent f48adef361
commit 925aae4f01
1 changed files with 6 additions and 2 deletions

View File

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