Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will Paginate: How change default page in links

I have two partial. The first have a common will_paginate but in the second will_paginate I need to change the links (default url) generated by will_paginate.

Please I need their answer.

Thanks

like image 287
maxiperez Avatar asked Nov 19 '25 00:11

maxiperez


2 Answers

You can use :param_name to change the query-string parameter:

<%= will_paginate @posts, :param_name => :posts_page %> 
<%= will_paginate @comments, :param_name => :comments_page %> 

Note that in your controller you must also change this:

@posts = Post.paginate :page => params[:posts_page] 
@comments = Comment.paginate :page => params[:comments_page] 

Try this

will_paginate(@some_collection, :params => { :controller => "foo", :action => "bar" })
like image 37
Gerry Avatar answered Nov 20 '25 14:11

Gerry



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!