#36 ✓invalid
scot

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

    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

    Chris Wanstrath June 13th, 2007 @ 11:43 PM

    • State changed from “open” to “invalid”
  • Mislav

    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.

  • scot

    scot June 13th, 2007 @ 11:43 PM

    Thanks,

    all working now.

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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket

Pages