Forum: Ruby on Rails paginating_find losing scope

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.
Scott (Guest)
on 2008-12-09 02:30
(Received via mailing list)

I'm having a problem with paginating_find losing the context of the
array it's paginating.

For example,

  URL:  http://localhost:3000/companies/1/users/1

  <% @tickets =, page => {:size =>
10, :current => params[:page]}) %>
  <% for ticket in @tickets %>
  <% end %>
  <%= paginating_links (@tickets) %>

The problem is 'paginating_links' is spitting out pagination URLs that
look like:


instead of:


Any ideas why it's losing the context of the company?

Thank you!

Scott (Guest)
on 2008-12-09 05:21
(Received via mailing list)
I figured out what is making this happen.  I have a routes file that

  map.resources :users, :has_many => [:tickets]
  map.resources :companies, :has_many => [:users]

Is the paginating_links method simply finding the first route?  Any
way to tell it the correct route/path?


Scott (Guest)
on 2008-12-09 18:50
(Received via mailing list)
Problem solved:

<%= paginating_links(@tickets, {:params =>
    {:controller => "companies/#{}/users/#{}/"},
    :window_size => 10}) %>

Thanks for the hint Alex!
This topic is locked and can not be replied to.