Table of Content
.json.jbuilder file, we use
json object to defile the output JSON node. the syntax in
json.any_name, Then passing the value as argument.
jsor.id(@album.id) will output
So, for the album show API, we can create a file named
Or we can create a new node by using the
json.name do |json| end block.
The following is an album information with the user basic information.
How about listind all the photos in the album?
The image_url is a little but tricky, the paperclip gem returns relative url only.
we can prepend the URL to the relative path, and the URL is composited by the
If you feel uncomfortable with the long string concatenation here, helper is the place to abstract that long line.
What’s next? We’re going to take a look at “Extracting view code to helpers”.