Skip to content

Instantly share code, notes, and snippets.

@vamsipavanmahesh
Last active January 20, 2017 16:15
Show Gist options
  • Save vamsipavanmahesh/f9d5d5d211598fb77c0f0b6bab4be36a to your computer and use it in GitHub Desktop.
Save vamsipavanmahesh/f9d5d5d211598fb77c0f0b6bab4be36a to your computer and use it in GitHub Desktop.
[
{
"info": {
"total_pages": 6
}
},
{
"id": "e71edff6-4b27-4d55-9721-c26714b7285d",
"heading": "This will make you go crazy",
"description": "watch this funny video of indian engineering colleges",
"url": "https://www.youtube.com/watch?v=4LiJuB20Ioo",
"credits": "Being Indian channel",
"created_at": "2017-01-10T02:34:36.870Z",
"updated_at": "2017-01-10T02:34:36.870Z",
"categories": [
{
"name": "Fun"
},
{
"name": "Computers"
}
]
},
{
"id": "6ea12084-15d2-470a-baed-ae4973af373b",
"heading": "story 2",
"description": "desc of story 2",
"url": "Sample url",
"credits": "sample credit",
"created_at": "2017-01-19T16:57:25.750Z",
"updated_at": "2017-01-19T16:57:25.750Z",
"categories": [
{
"name": "Computers"
}
]
},
{
"id": "89fd266f-bf06-4b29-9081-1b3631fbde82",
"heading": "story 2",
"description": "desc of story 2",
"url": "Sample url",
"credits": "sample credit",
"created_at": "2017-01-19T16:57:56.673Z",
"updated_at": "2017-01-19T16:57:56.673Z",
"categories": [
{
"name": "Computers"
}
]
},
{
"id": "619af3e9-02da-4892-8c4b-e220c366eefe",
"heading": "story 2",
"description": "desc of story 2",
"url": "Sample url",
"credits": "sample credit",
"created_at": "2017-01-19T16:57:57.501Z",
"updated_at": "2017-01-19T16:57:57.501Z",
"categories": [
{
"name": "Computers"
}
]
},
{
"id": "e3fc434f-91a7-4b32-8ea0-cc412a2f7bfd",
"heading": "story 2",
"description": "desc of story 2",
"url": "Sample url",
"credits": "sample credit",
"created_at": "2017-01-19T16:57:58.008Z",
"updated_at": "2017-01-19T16:57:58.008Z",
"categories": [
{
"name": "Computers"
}
]
}
]
def index
stories = Story.paginate(page: params[:page] || 1, per_page: 5)
obj = []
information = {}
information['total_pages'] = stories.total_pages
new_hash = {}
new_hash['info'] = information
obj << new_hash
stories.each do |story|
obj << story.details
end
render json: obj
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment