For Ruby on Rails, how do you use will_paginate or Kaminari when the data is fetched from an API? (over the net)?

I already do pagination on a non-AR set for my acts_as_indexed plugin.

I already do pagination on a non-AR set for my acts_as_indexed plugin. In your case it would work something like the following: def fetch(page=1, per_page=10) total_entries = 1000 # Or whatever method you choose to find the total entries. Returning ::WillPaginate::Collection.

New(page, per_page, total_entries) do |pager| url = "foo.com/fetch_data?type=products&offset=... results = fetch_example(url)# fetch the actual data here. Pager. Replace results end end Controller: def index @records = fetch(params:page) end Views: Fill in your own methods for fetching and processing the data, and working out the total entries.

Hm, implementing the page numbers, how many before, how many after, and if page_number_max, then can't show it, and wanting to show 5 page numbers constantly, these kind of things can be messy. Are there standard helpers or common gem that can do it? – 動靜能針 Apr 1 at 13:52 Remembered I actually use WillPaginate in a plugin I maintain in a manner that would be useful to you.

Have revamped my answer using this method. Allows you to use the nice will_paginate view helpers etc.– Douglas F Shearer Apr 1 at 15:09.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions