I have a model that connects to an external database and I query using the find_by_sql method like so:
External.find_by_sql("SELECT * from table")
However when I add the .page(params[:page]), the error "undefined method page for class array" appears. Is it possible to paginate the results fetched using find_by_sql?
This worked for me:
Kaminari.paginate_array(my_array_object).page(params[:page]).per(10)
https://github.com/kaminari/kaminari/wiki/Kaminari-recipes#-how-do-i-paginate-an-array
If you cannot avoid using find_by_sql, check out last question of kaminari wiki.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With