Ckt22
Ckt22

Reputation: 191

Kaminari's pagination toggle next page has no effect and no error message

I'm using Ruby on Rails to make a website and use Ransack to sort my output records (list). I installed Kamimari because it can paginate every 10 records.

At present, I only have 5 records, so I first set "every 3 records" to be able to paginate. I do see a hyperlink of "Next" to the number "2". But when I press the hyperlinks, the page doesn't change at all, and there is no error message, but the end of the URL becomes "&page=2", it just doesn't move at all. Is this my data is too few? Or is there something missing?

This is part of my controller

  def list
    @query = current_user.tasks.ransack(params[:q])
    @tasks = @query.result.page(1).per(3)
  end

This is part of my view, the "list_tasks_path" is a route to my homepage (list).

<%= link_to t('task_do_add') , list_tasks_path %>

Upvotes: 0

Views: 121

Answers (1)

Yakov
Yakov

Reputation: 3191

You always fetch the first page page(1) you should take the page parameter into account @query.result.page(params[:page]).per(3).

Upvotes: 1

Related Questions