Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Exception in Rails 2.3.2 when using :group

#268

Using will_paginate-2.3.8 with Rails 2.3.2 raises an exception when using :group

Example:


 User.paginate :all, :finder => 'count', :group => 'country', :page => 1
TypeError: can't convert ActiveSupport::OrderedHash into Array
from /usr/lib/ruby/gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/collection.rb:135:in `replace'
from /usr/lib/ruby/gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/collection.rb:135:in `replace'
from /usr/lib/ruby/gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:82:in `paginate'
from /usr/lib/ruby/gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/collection.rb:87:in `create'
from /usr/lib/ruby/gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:76:in `paginate'
from (irb):5

This is because in Rails 2.3.2, OrderedHash changed from being a subclass of Array to a subclass of Hash.

Reported by Paco Benavent · April 17th, 2009 @ 12:58 PM

State: open
Milestone: none
Assigned to: Mislav Mislav

Activity

  1. Mislav
    Mislav
    • State changed from new to open

    Good catch. Will try to fix soon

    April 17th, 2009 @ 08:25 PM

  2. Paco Benavent
    Paco Benavent

    Thank you for your response!

    I made a quick fix that worked for me, changing line 82 in finder.rb

    from:

    
        pager.replace(send(finder, *args) { |*a| yield(*a) if block_given? })
    

    to:

    
        pager.replace(send(finder, *args) { |*a| yield(*a) if block_given? }.to_a)
    

    Hope it'll help.

    April 21st, 2009 @ 03:30 PM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.