pagination not working when using edge rails
Reported by scot | June 13th, 2007 @ 11:43 PM
The following find code is used in the controller
@news = News.paginate(:per_page => 2,
:include => :user,
:order => 'news.created_at DESC')
when <%= will_paginate @news %> is included in the view
« Previous 1 2 3 Next » is displayed however when you go to http://localhost:3000/news?page=2 the pagination does not work and the same results are fetched along with the pagination links not changing.
Comments and changes to this ticket
-
Chris Wanstrath June 13th, 2007 @ 11:43 PM
- State changed from new to open
Try passing in the :page.
@news = News.paginate(:per_page => 2, :include => :user, :order => 'news.created_at DESC', :page => params[:page])
-
Chris Wanstrath June 13th, 2007 @ 11:43 PM
- State changed from open to invalid
-
Mislav June 13th, 2007 @ 11:43 PM
Scot: as Chris said, you have to pass the page parameter explicitly. This is because the model can't access controller params. If it could, the page parameter would be optional.
The :page=>params[:page] repetition bugs me, too. I would like to avoid it somehow, but still stay clean with MVC.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »