0
votes

{ "status": {"code"=>-10000, "message"=>"validation error"}, "results":[], "errors": @search_form.errors }

normally we write format.json { render json: @org.errors, status: :unprocessable_entity }

to get above json format how I need to write.

1

1 Answers

1
votes

Creating any JSON response is easy with a JSON template engine, for example, JBuilder. For a detailed screencast, see this screencast by Ryan Bates.

The basic idea is to create a shared view template that would format your errors as you wish and send it back to the browser.