#247 ✓invalid
Dipesh Batheja

will_paginate helper doesn't work with has_and_belongs_to_many associations.

Reported by Dipesh Batheja | September 24th, 2008 @ 04:52 PM

Here is how my Product model looks like:

class Product < ActiveRecord::Base has_and_belongs_to_many :categories, :join_table => "products_categories" end

In my controller, i have done this: @products = @current_category.products.paginate :per_page => 12, :page => params[:page]

will_paginate helper doesn't show pages in the view. If manually pass page param in url, it work just fine. But will_paginate helper does not show the pages list and next and prev links.

Comments and changes to this ticket

  • Mislav

    Mislav October 7th, 2008 @ 09:10 PM

    • Assigned user changed from “Chris Wanstrath” to “Mislav”
    • State changed from “new” to “open”
    • Tag set to will_paginate

    Hey,

    You didn't assign the ticket to me or tagged it "will_paginate", so I missed it. Has this been resolved for you in the meantime? If not, can you please provide more detail

    Thanks

  • Ivan

    Ivan December 9th, 2008 @ 04:46 AM

    Hey, I'm having the same problem, with the following model:

    class Playlist < ActiveRecord::Base has_and_belongs_to_many :songs end

    When I call @songs = Playlist.find(123).songs.paginate(:page => '1', :per_page => '20') The @songs variable is set with 20 songs, but when calling @songs.total_entries and total_pages, the result is 0. That's strange...

  • Mislav

    Mislav December 9th, 2008 @ 04:00 PM

    • State changed from “open” to “invalid”

    This is because of a bug in ActiveRecord with Ruby 1.8.7.

    I've investigated and it looks like ruby 1.8.7 + ActiveRecord 2.1.1 = FAIL

    It's been fixed in Rails commit 44af2e.

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!

Pages