views:

10

answers:

1

I'm using will_paginate (3.0.pre2) with rails 3.0.0.rc. The first page pulls up fine but when I go to page 2, it returns nothing because the query for page 2 is not being set correctly by will_paginate.

Controller:

page = params['page'].blank? ? 1 : params['page']
@posts = Post.paginate_by_sql (['select * from Foo_Table where ids = ?', params[:ids]], :page=>page, :per_page=>50)
@pag_params = {:ids=>params[:ids]}

View:

<%= will_paginate @posts, :params=>@pag_params %>

Link to page 2 is:

http://localhost:3000/posts/search?page=2&amp;ids=1

Logs show the where clause show an incorrect (ids = 'search') when it should be (ids = '1')

SELECT * FROM `Foo_Table` WHERE (ids = 'search')

What am I missing so that the query for page 2 can be corrected?

A: 

Talked to the developer of of will_paginate and found out that the best way to attack this is by using scoped_by_column_name(...column_value...).paginate(...conditions...)

Hope this helps someone. :)