Forum: Ruby on Rails Pagination_links without "?page=" but with params[:id]

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
19403f509ca90e8ffe072214c6cba896?d=identicon&s=25 oo00oo (Guest)
on 2006-01-19 16:08
(Received via mailing list)
Hello,

With default pagination I have this :

<a href="/users/infos/3?page=1">1</a>
<a href="/users/infos/3?page=3">3</a>

but i need this :

<a href="/users/infos/1">1</a>
<a href="/users/infos/3">3</a>


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:
***

<a href="/users/infos/3?page=1">1</a> 2
<a href="/users/infos/3?page=3">3</a>  ...
<a href="/users/infos/3?page=6">6</a>
82476266af9d460415d8f1fc16bb54ed?d=identicon&s=25 Jarkko Laine (jarkko)
on 2006-01-19 16:35
(Received via mailing list)
On 19.1.2006, at 16.31, oo00oo wrote:

> <a href="/users/infos/3">3</a>
>
>
> 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 Laine
http://jlaine.net
http://odesign.fi
19403f509ca90e8ffe072214c6cba896?d=identicon&s=25 oo00oo (Guest)
on 2006-01-19 16:53
(Received via mailing list)
Ok, thanks, with :parameter => "id" , the correct page are now selected
in the paginate links but how remove the "?page=" ?

How rewrite  <a href="/users/infos/3?page=1">1</a>   to   <a
href="/users/infos/1">1</a>   ?
82476266af9d460415d8f1fc16bb54ed?d=identicon&s=25 Jarkko Laine (jarkko)
on 2006-01-19 16:59
(Received via mailing list)
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  <a href="/users/infos/3?page=1">1</a>   to   <a href="/
> users/infos/1">1</a>   ?
>

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] http://api.rubyonrails.com/classes/ActionView/Helpers/
PaginationHelper.html#M000349

> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>

--
Jarkko Laine
http://jlaine.net
http://odesign.fi
71f1b6b2c3fd9af2e8c52618fb91caa6?d=identicon&s=25 Jules Jacobs (jules)
on 2006-01-19 17:00
in routes.rb:

map.connect ':controller/:action/:id/:page'
71f1b6b2c3fd9af2e8c52618fb91caa6?d=identicon&s=25 Jules Jacobs (jules)
on 2006-01-19 17:01
Whoops:

':controller/:action/:page'
19403f509ca90e8ffe072214c6cba896?d=identicon&s=25 oo00oo (Guest)
on 2006-01-19 17:09
(Received via mailing list)
Oh yeah

that work with

map.connect ':controller/:action/:page'

This is so simple. Incredible !

Thanks to all :)
19403f509ca90e8ffe072214c6cba896?d=identicon&s=25 oo00oo (Guest)
on 2006-01-19 17:27
(Received via mailing list)
_______________________________________________
Rails mailing list
Rails@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails
19403f509ca90e8ffe072214c6cba896?d=identicon&s=25 oo00oo (Guest)
on 2006-01-19 18:39
(Received via mailing list)
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/HowToRoute...
)
have default route at the bottom

Why this error ?
This topic is locked and can not be replied to.