0
How to create an API using ruby on rails?
I need code which help me to understand the creation of API which provides data in json form and consume that json in my Android app.
1 Réponse
0
Rails allows you to export your output directly to JSON.
http://guides.rubyonrails.org/layouts_and_rendering.html#using-render
2.2.8 Rendering JSON
JSON is a JavaScript data format used by many Ajax libraries. Rails has built-in support for converting objects to JSON and rendering that JSON back to the browser:
render json: @product
You don't need to call to_json on the object that you want to render. If you use the :json option, render will automatically call to_json for you