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.

will_paginate helper doesn't work with has_and_belongs_to_many associations.

#247

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.

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

State: invalid
Milestone: none
Assigned to: Mislav Mislav

Activity

  1. Mislav
    Mislav
    • 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

    October 7th, 2008 @ 09:10 PM

  2. Ivan
    Ivan

    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...

    December 9th, 2008 @ 04:46 AM

  3. Mislav
    Mislav
    • 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.

    December 9th, 2008 @ 04:00 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.