Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

pagination not working when using edge rails

#36

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.

Reported by scot · June 13th, 2007 @ 11:43 PM

State: invalid
Milestone: none
Assigned to: Chris Wanstrath Chris Wanstrath

Activity

  1. Chris Wanstrath
    Chris Wanstrath
    • 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])
    

    June 13th, 2007 @ 11:43 PM

  2. Chris Wanstrath
    Chris Wanstrath
    • State changed from open to invalid

    June 13th, 2007 @ 11:43 PM

  3. Mislav
    Mislav

    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.

    June 13th, 2007 @ 11:43 PM

  4. scot
    scot

    Thanks,

    all working now.

    June 13th, 2007 @ 11:43 PM

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.