#268 open
Paco Benavent

Exception in Rails 2.3.2 when using :group

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

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.

Comments and changes to this ticket

  • Mislav

    Mislav April 17th, 2009 @ 08:25 PM

    • State changed from “new” to “open”

    Good catch. Will try to fix soon

  • Paco Benavent

    Paco Benavent April 21st, 2009 @ 03:30 PM

    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.

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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Everyone's favorite Ruby library for pagination of practically anything!

People watching this ticket

Pages