Actually guys it very simple to to send a json or xml response in the ruby on rails. But in most of the cases people didn’t knew about what is a json response and what is an xml response.
In an application we use json and xml responses to write the API for our application now a new question arises in mind What is and API Application Programming Interface it is used to enhance the capability of our web application so that it could interact with other website or devices over the network in terms of data exchange. But a good method is to write an Web service for data exchange over the network. But that is another vast area , however lets concentrate on our aim first.
Firstly lets create an new rails app by:
$rails new exercise -d mysql $cd exercise $rails generate model user name:string email_id:string age:integer $rails generate controller user index send_json send_xml $rake db:migrate