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.

paginate_each with conditions

#206

Hey Mislav, it looks like I found a tiny bug in WP 2.2.1

I wanted to use the awesome new paginate_each method with a condition and tried the following:

User.paginate_each(:page => 1, :conditions => ["user.zip_code IN (?)", @zip_codes])

The first thing was that it forced to manually enter a page number, which is not the case when I don't use a conditions, the second id that it raised an error:

NoMethodError: undefined method `find_each' for #

from vendor/rails/activerecord/lib/active_record/base.rb:1624:in `method_missing_without_paginate'

from vendor/gems/will_paginate-2.2.1/lib/will_paginate/finder.rb:164:in `method_missing'

from vendor/gems/will_paginate-2.2.1/lib/will_paginate/finder.rb:82:in `send'

from vendor/gems/will_paginate-2.2.1/lib/will_paginate/finder.rb:82:in `paginate'

from vendor/gems/will_paginate-2.2.1/lib/will_paginate/collection.rb:87:in `create'

from vendor/gems/will_paginate-2.2.1/lib/will_paginate/finder.rb:76:in `paginate'

from vendor/gems/will_paginate-2.2.1/lib/will_paginate/finder.rb:177:in `method_missing'

Am I missing something or is that a bug?

Thanks,

-Matt

Reported by Matt Aimonetti (mattetti) · April 11th, 2008 @ 03:11 AM

State: invalid
Milestone: none
Assigned to: Mislav Mislav

Activity

  1. Mislav
    Mislav
    • State changed from new to resolved

    Hey Matt,

    It's paginated_each (you are missing a letter). I see how you got confused, but I think this name is more semantic with regard to what the method does.

    April 11th, 2008 @ 03:37 AM

  2. Mislav
    Mislav
    • State changed from resolved to invalid

    April 11th, 2008 @ 03:38 AM

  3. Matt Aimonetti (mattetti)
    Matt Aimonetti (mattetti)
    • Title changed from pageinate_each with conditions to paginate_each with conditions

    aaahhh I knew it was something stupid like that!

    I agree paginated is probably semantically better.

    Works great, I'm glad you added this feature. Btw you might want to document it in the readme file.

    April 11th, 2008 @ 07:30 AM

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.