I have a custom model (not mapping by any tables under database). This custom model is just the result of union many other table's data. I want to use kaminari for paginate this.
for example:
def index
@custom_models = find_all_items # result is an array
render
end
And then i paginate those items on view:
= paginate @custom_models
When I run this, I meet exception:
undefined method `total_pages' for Array:0x007fb4dde63c70
My question is: how can I use Kaminari for custom model file.
@Edit I can use Kaminari now, just use this line:
@custom_models = Kaminari.paginate_array(@custom_models)
.page(params[:page]).per(params[:per_page])
But now I meet problem: because this is custom model, I'm using custom query. I use raw sql query and paginate by myself using offset and limit keyword.
For example I return 25 records, and default of Kaminari is displaying 25 records each pages so I can only see 1 page. I can make query for returning total necessary records (for example 1000 records) but I don't know how to make Kaminari understand this and show me enough pages.
thanks