ruby-on-railspaginationfind-by-sql

find_by_sql and pagination with kamanari


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?


Solution

  • If you cannot avoid using find_by_sql, check out last question of kaminari wiki.