# Pagination\_links without "?page=" but with params\[:id\]

**URL:** <https://www.ruby-forum.com/t/pagination-links-without-page-but-with-params-id/52833>\
**Category:** Rails\
**Created:** [January 19, 2006, 4:08pm UTC](https://www.ruby-forum.com/t/pagination-links-without-page-but-with-params-id/52833 "2006-01-19T16:08:41Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![oo00oo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/8797f3/32.png) [@oo00oo](https://www.ruby-forum.com/u/oo00oo)\
**Post date:** [January 19, 2006, 4:08pm UTC](https://www.ruby-forum.com/t/pagination-links-without-page-but-with-params-id/52833/1 "2006-01-19T16:08:41Z")

</div>

Hello,

With default pagination I have this :

[1](https://www.ruby-forum.com/users/infos/3?page=1)  
[3](https://www.ruby-forum.com/users/infos/3?page=3)

but i need this :

[1](https://www.ruby-forum.com/users/infos/1)  
[3](https://www.ruby-forum.com/users/infos/3)

I need to remove the “?page=” parameters and rewrite a little the link (  
with a link\_to ? )

How can I do this ?  
Need to use pagination\_links\_each ? Use options ?

Thanks

controller :

* * *

@paginate\_pages, @users = paginate :users, :per\_page =\> 1, :order =\>  
“id DESC”

view:

* * *

\<%= pagination\_links @paginate\_pages, :window\_size =\> 1 %\>

in html:

* * *

[1](https://www.ruby-forum.com/users/infos/3?page=1) 2  
[3](https://www.ruby-forum.com/users/infos/3?page=3) …  
[6](https://www.ruby-forum.com/users/infos/3?page=6)

---

<div class="post-metadata">

**Author:** ![oo00oo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/8797f3/32.png) [@oo00oo](https://www.ruby-forum.com/u/oo00oo)\
**Post date:** [January 19, 2006, 4:35pm UTC](https://www.ruby-forum.com/t/pagination-links-without-page-but-with-params-id/52833/2 "2006-01-19T16:35:48Z")

</div>

On 19.1.2006, at 16.31, oo00oo wrote:

> [3](https://www.ruby-forum.com/users/infos/3)
> 
> I need to remove the “?page=” parameters and rewrite a little the  
> link ( with a link\_to ? )
> 
> How can I do this ?

Set the :parameter option for paginate to ‘id’.

Example from typo:  
@articles\_pages, @articles = paginate :article, :per\_page =\>  
15, :order\_by =\> “created\_at DESC”, :parameter =\> ‘id’

//jarkko

–  
Jarkko L.

> **[jlaine.net](https://jlaine.net/)**
>
> Your freedom to carry a gun messes with my freedom to walk around without fear. Your freedom to “stand your ground” with force is at odds with my …

[http://odesign.fi](http://odesign.fi)

---

<div class="post-metadata">

**Author:** ![oo00oo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/8797f3/32.png) [@oo00oo](https://www.ruby-forum.com/u/oo00oo)\
**Post date:** [January 19, 2006, 4:53pm UTC](https://www.ruby-forum.com/t/pagination-links-without-page-but-with-params-id/52833/3 "2006-01-19T16:53:54Z")

</div>

Ok, thanks, with :parameter =\> “id” , the correct page are now selected  
in the paginate links but how remove the “?page=” ?

How rewrite [1](https://www.ruby-forum.com/users/infos/3?page=1) to [1](https://www.ruby-forum.com/users/infos/1) ?

---

<div class="post-metadata">

**Author:** ![oo00oo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/8797f3/32.png) [@oo00oo](https://www.ruby-forum.com/u/oo00oo)\
**Post date:** [January 19, 2006, 5:00pm UTC](https://www.ruby-forum.com/t/pagination-links-without-page-but-with-params-id/52833/4 "2006-01-19T17:00:45Z")

</div>

in routes.rb:

map.connect ‘:controller/:action/:id/:page’

---

<div class="post-metadata">

**Author:** ![oo00oo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/8797f3/32.png) [@oo00oo](https://www.ruby-forum.com/u/oo00oo)\
**Post date:** [January 19, 2006, 4:59pm UTC](https://www.ruby-forum.com/t/pagination-links-without-page-but-with-params-id/52833/5 "2006-01-19T16:59:56Z")

</div>

On 19.1.2006, at 17.15, oo00oo wrote:

> Ok, thanks, with :parameter =\> “id” , the correct page are now  
> selected in the paginate links but how remove the “?page=” ?
> 
> How rewrite [1](https://www.ruby-forum.com/users/infos/3?page=1) to 1 ?

Again, from typo:  
\<%= link\_to “Previous page”, { :id =\> pages.current.previous }  
if pages.current.previous -%\>  
\<%= pagination\_links pages, :name =\> ‘id’ -%\>  
\<%= link\_to “Next page”, { :id =\> pages.current.next } if  
pages.current.next -%\>

The name variable in pagination\_links should be interesting to you.  
See the api docs for pagination\_links [1].

//jarkko

[1] [Peak Obsession](http://api.rubyonrails.com/classes/ActionView/Helpers/)  
PaginationHelper.html#M000349

> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–  
Jarkko L.

> **[jlaine.net](https://jlaine.net/)**
>
> Your freedom to carry a gun messes with my freedom to walk around without fear. Your freedom to “stand your ground” with force is at odds with my …

[http://odesign.fi](http://odesign.fi)

---

<div class="post-metadata">

**Author:** ![oo00oo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/8797f3/32.png) [@oo00oo](https://www.ruby-forum.com/u/oo00oo)\
**Post date:** [January 19, 2006, 5:01pm UTC](https://www.ruby-forum.com/t/pagination-links-without-page-but-with-params-id/52833/6 "2006-01-19T17:01:19Z")

</div>

Whoops:

‘:controller/:action/:page’

---

<div class="post-metadata">

**Author:** ![oo00oo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/8797f3/32.png) [@oo00oo](https://www.ruby-forum.com/u/oo00oo)\
**Post date:** [January 19, 2006, 5:09pm UTC](https://www.ruby-forum.com/t/pagination-links-without-page-but-with-params-id/52833/7 "2006-01-19T17:09:00Z")

</div>

Oh yeah

that work with

map.connect ‘:controller/:action/:page’

This is so simple. Incredible !

Thanks to all 🙂

---

<div class="post-metadata">

**Author:** ![oo00oo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/8797f3/32.png) [@oo00oo](https://www.ruby-forum.com/u/oo00oo)\
**Post date:** [January 19, 2006, 5:27pm UTC](https://www.ruby-forum.com/t/pagination-links-without-page-but-with-params-id/52833/8 "2006-01-19T17:27:10Z")

</div>

* * *

Rails mailing list  
removed\_email\_address@domain.invalid  
[http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

---

<div class="post-metadata">

**Author:** ![oo00oo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/8797f3/32.png) [@oo00oo](https://www.ruby-forum.com/u/oo00oo)\
**Post date:** [January 19, 2006, 6:39pm UTC](https://www.ruby-forum.com/t/pagination-links-without-page-but-with-params-id/52833/9 "2006-01-19T18:39:40Z")

</div>

Just a little question about routes.rb

if I wrote this :

map.connect ‘:controller/:action/:id’  
map.connect ‘:controller/:action/:page’ , :controller =\> “users”

everything is ok. But if I swap the line oder to :

map.connect ‘:controller/:action/:page’ , :controller =\> “users”  
map.connect ‘:controller/:action/:id’

I have the error :  
ActiveRecord::RecordNotFound in Users#infos

Couldn’t find User without an ID

It’s strange because we need to " # Install the default route as the  
lowest priority. "  
And all example I have seen (  
[http://wiki.rubyonrails.com/rails/pages/HowToRouteGenericURLsToAController](http://wiki.rubyonrails.com/rails/pages/HowToRouteGenericURLsToAController)  
)  
have default route at the bottom

Why this error ?
