oo00oo
1
Hello,
With default pagination I have this :
1
3
but i need this :
1
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 2
3 …
6
oo00oo
2
On 19.1.2006, at 16.31, oo00oo wrote:
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.
http://odesign.fi
oo00oo
3
Ok, thanks, with :parameter => “id” , the correct page are now selected
in the paginate links but how remove the “?page=” ?
How rewrite 1 to 1 ?
oo00oo
4
in routes.rb:
map.connect ‘:controller/:action/:id/:page’
oo00oo
5
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 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
PaginationHelper.html#M000349
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails
–
Jarkko L.
http://odesign.fi
oo00oo
6
Whoops:
‘:controller/:action/:page’
oo00oo
7
Oh yeah
that work with
map.connect ‘:controller/:action/:page’
This is so simple. Incredible !
Thanks to all
oo00oo
8
oo00oo
9
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
)
have default route at the bottom
Why this error ?