Table of Content
In the past, we output JSON in controller.
But it has been like a hacking with lot’s of nesting block while the JSON format grows.
But the controller JSON story is over. Now we can define how the data is formatted in JSON, as same as how the data is organized in HTML. This are done by a gem named “JBuilder” from the official rails team. And it is now pre-installed in rails version 4.
Gemfile, uncomment the following line and
bundle install it.
JBuilder gem uses file extension
.json.jbuilder. This follows the extension convention like
What’s next? We’re going to take a look at “Using jbuilder”.