0

Assuming following model:

class Account < ActiveRecord::Base
  has_many :orders
end

class Order < ActiveRecord::Base
  belongs_to :account

  scope :active, -> { where('orders.state = ?', 'ACTIVE') }
  scope :closed, -> { where('orders.state <> ?', 'ACTIVE') }

end

In account/show view I have two lists: one for active orders and other with closed ones.

Now I need to add a paging for each of the lists (using will_paginate gem) but I don't know what is the best way to route the requests for that and how to handle two collections in the controller action.

Michael D.
  • 1,249
  • 2
  • 25
  • 44

1 Answers1

0

As explained here, you need to set to set different :param_name values for your two calls to will_paginate:

<%= will_paginate @orders.active, :param_name => 'active_page' %>
<%= will_paginate @orders.closed, :param_name => 'closed_page' %>

https://github.com/mislav/will_paginate/wiki/API-documentation

Community
  • 1
  • 1
tirdadc
  • 4,603
  • 3
  • 38
  • 45