Forum: Ruby on Rails Pagination error using named routes

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
454f52683cda0650127b319762bcd529?d=identicon&s=25 Jan Eden (janeden)
on 2007-07-17 20:32

I repeatedly get pagination errors (cannot convert Fixnum to String)
when using a certain order of routes. This order works fine:

  map.connect 'maerchen', :controller => 'pages', :action => 'index',
:id => 8
  map.connect 'erzaehlungen', :controller => 'pages', :action =>
'index', :id => 2597
  map.connect 'gedichte', :controller => 'pages', :action => 'index',
:id => 7

  map.connect 'pages/:id.:format', :controller => 'pages', :action =>
'index', :requirements => { :id => /\d+/ }
  map.connect 'pages/:id', :controller => 'pages', :action => 'index',
:requirements => { :id => /\d+/ }
  map.connect ':id', :controller => 'pages', :action => 'index',
:requirements => { :id => /\d+/ }

I can access both http://host/gedichte http://host/7, or
http://host/pages/7 to get a nice paginated output using

  <% @children_pagination.each do |page| %>
    <%= link_to_unless((params[:page].to_i == page.number),
"#{(page.number*20-19).to_s}-#{(page.number*20).to_s}", :page => page)
  <% end %>

But as soon as I move one of the non-named routes to the top, the named
URLs (http://host/gedichte) etc. throw the error above.

Why is that?

Kind regards,
This topic is locked and can not be replied to.