#215 ✓resolved
Patrick

will_paginate causing SystemStackError on has_many :through associations

Reported by Patrick | May 4th, 2008 @ 02:01 PM

On edge rails (commit 64092de25727c1943807bf5345107d90428135a0 if that helps), using latest will_paginate. Added named_scopes to my Product model which are working GREAT so far. However, I'm getting the following error when I call any methods on a has_many :through collection. For instance, calling @product.categories.first results in

SystemStackError: stack level too deep
in .../vendor/plugins/will_paginate/lib/will_paginate/finder.rb:164:in `method_missing_without_paginate'

I've seen similiar complaints as these on older versions of Rails, but folks seemed to have resolved them. Any ideas?

Comments and changes to this ticket

  • E. James O'Kelly

    E. James O'Kelly May 4th, 2008 @ 06:09 PM

    I am experiencing the same result. Here is my pagination code that throws the issue. It is when dealing with a model that has a has_many :through association proxy. If you attempt to access that collection it throws the stack too deep exception in finder.rb of will_paginate.

    class Mentor < User
      has_many :mentor_specialties, :dependent => :destroy
      has_many :specialties, :through => :mentor_specialties
    
    def self.page(page)
        paginate :include => [:specialties], :page => page, :per_page => 9
      end
      
      def self.search(specialty, page)
        if specialty.blank?
          paginate :include => [:specialties], :page => page, :per_page => 9
        else
          Mentor.find(:all, :include => [:mentor_specialties, :specialties], 
            :conditions => ["mentor_specialties.specialty_id = ?", Specialty.find(specialty)]).paginate :page => page, :per_page => 9
        end
      end
    end
    

    You will notice this class inherits from another class that handles the activerecord, this is just an sti subclass.

  • Patrick

    Patrick May 6th, 2008 @ 10:41 AM

    The latest checkout from Github (2.3.1) fixes this problem: http://github.com/mislav/will_pa...

    Thanks guys!!

  • Mislav

    Mislav June 11th, 2008 @ 05:13 AM

    • State changed from “new” to “resolved”
    • Assigned user changed from “Chris Wanstrath” to “Mislav”

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 ยป

Shared Ticket Bins

Pages