Mohnish J.
2013-Mar-14 04:45 UTC
Display custom links above top level arrays using Jbuilder
I have a custom JSON response in which I display a collection of 15 posts along with related data like comments etc., as part of an API call. I am displaying the entire collection using Jbuilder . json.array!(@posts) do |post| .. .. end I want to display pagination links above the response of the 15 posts, in order to get the next set of posts with the appropriate next set of next page and prev page pagination links. In my abc.json.jbuilder file if I try doing it as per the below code, I don''t get links to the next and prev page as part of my json response. json.pagination_links do json.set!(:next_page_link,"#{@next_page_link}") json.set!(:prev_page_link,"#{@prev_page_link}") end json.array!(@posts) do |post| .. .. end The only response, that I get is the array which has a collection of posts. Which looks like below:- [ -{post1} -{post2} -.. ] I guess there is something that I might be missing. Can anybody please suggest me any work arounds? Thanks. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.