This project is archived and is in readonly mode.

#3316 ✓duplicate
Ryan Bigg

has_many :through with :conditions fails

Reported by Ryan Bigg | October 3rd, 2009 @ 11:47 PM

From Stackoverflow ("Eric"):

I would put the models in here but Lighthouse's formatting is so sporadic that it munges it.

Given the models in:

When I run "rake observer" I get:

Membership(#2174755620) expected, got Array(#2148226700)

I haven't yet investigated where the array is coming from, perhaps after breakfast.

Comments and changes to this ticket

  • Ryan Bigg

    Ryan Bigg October 4th, 2009 @ 12:35 AM

    Upon further investigation it appears that changing the conditions line from:

    :conditions => { :memberships => { :observer => true }}


    :conditions => [" = ?", true]

    fixes the problem.

    The association.replace() call around line #1322 of associations.rb passes in a hash where it appears it should be passing in an array. The caller chain of this leads me to attributes= on line #2732 of base.rb, which gets the key of "memberships" having the value of {:observer => true }. With the Array conditions hash this never occurs, the only output I see from this method is the "name" key having a value of "Joe Student".

  • John Trupiano

    John Trupiano October 4th, 2009 @ 12:49 AM

    If I'm not mistaken, this is a duplicate of #2998 ( ) for which I've submitted a patch. A +1 there would be helpful.

  • Ryan Bigg

    Ryan Bigg June 23rd, 2010 @ 01:27 PM

    • State changed from “new” to “duplicate”

    Duplicate of #2998.

Create your profile

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

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

Referenced by