Pagination and custom routing

Hello all, I’m new to RoR but loving leanrning it and wish i’d found it
earlier instead of spending so much time with PHP.

I have a problem with a custom routing and pagination… In my
application, users can save their favourite bookmarks, and can view each
others favourites. I have set up rooting so they can do this easily by
the URL www.mysite.com/username using the following route -

map.connect ‘:username’, :controller => ‘links’, :action => ‘per_user’

This works fine and sends them to the correct controller, links, where
the action per_user paginates a list of bookmarks depending on the
username defined by :username in the map.connect above.

The action that generates the pages looks like this -

user = User.find_by_login(@params[:username])
@bookmark_pages, @bookmarks = paginate(:bookmarks, :conditions =>
[‘user_id = ?’, user.id])

The first page of results works fine, i can type www.mysite.com/dave for
instance, and i recieve the first page of my bookmarks.

The problem is with the rest of the pages, the link to page 2 appears as

www.mysite.com/links/per_user?page=2

where i’d like it to be

www.mysite.com/dave?page=2

Is this a problem with my routing, I can’t seem to figure this one out,
any help at all appreciated, thanks in advance.

Just sorted it, it was the order of the route mapping in routes.rb.
I had my custom route below the default :controller/:action/:id , so it
seems when paginate was generating the links this map was catching it
first. I just moved my route above this and paginate generates the URLs
as required.