oo00oo
2006-Jan-19 14:31 UTC
[Rails] Pagination_links without "?page=" but with params[:id]
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>
Jarkko Laine
2006-Jan-19 14:58 UTC
[Rails] Pagination_links without "?page=" but with params[:id]
On 19.1.2006, at 16.31, oo00oo wrote:> 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 ?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
oo00oo
2006-Jan-19 15:15 UTC
[Rails] Pagination_links without "?page=" but with params[:id]
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> ?> > 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
2006-Jan-19 15:22 UTC
[Rails] Pagination_links without "?page=" but with params[:id]
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>> >> 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 >> > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Jarkko Laine http://jlaine.net http://odesign.fi
Jules Jacobs
2006-Jan-19 15:24 UTC
[Rails] Re: Pagination_links without "?page=" but with params[:id]
in routes.rb: map.connect '':controller/:action/:id/:page'' -- Posted via http://www.ruby-forum.com/.
Jules Jacobs
2006-Jan-19 15:25 UTC
[Rails] Re: Pagination_links without "?page=" but with params[:id]
Whoops: '':controller/:action/:page'' -- Posted via http://www.ruby-forum.com/.
oo00oo
2006-Jan-19 15:29 UTC
[Rails] Re: Pagination_links without "?page=" but with params[:id]
Oh yeah that work with map.connect '':controller/:action/:page'' This is so simple. Incredible ! Thanks to all :)> in routes.rb: > > map.connect '':controller/:action/:id/:page'' > >
oo00oo
2006-Jan-19 15:49 UTC
Re: Re: Pagination_links without "?page=" but with params[:id]
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 ? Whoops: '':controller/:action/:page'' _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
oo00oo
2006-Jan-19 17:00 UTC
[Rails] Re: Pagination_links without "?page=" but with params[:id]
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 ?