This project is archived and is in readonly mode.
has_many :through with :conditions fails
Reported by Ryan Bigg | October 3rd, 2009 @ 11:47 PM
From Stackoverflow ("Eric"): http://stackoverflow.com/questions/1514880/how-can-i-create-new-rec...
I would put the models in here but Lighthouse's formatting is so sporadic that it munges it.
Given the models in: http://github.com/radar/course-student-membership-bug
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 October 4th, 2009 @ 12:35 AM
Upon further investigation it appears that changing the conditions line from:
:conditions => { :memberships => { :observer => true }}
to
:conditions => ["memberships.observer = ?", 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 October 4th, 2009 @ 12:49 AM
If I'm not mistaken, this is a duplicate of #2998 ( https://rails.lighthouseapp.com/projects/8994/tickets/2998-named_sc... ) for which I've submitted a patch. A +1 there would be helpful.
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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Referenced by
- 2998 [PATCH] SQL generated by find ignores :include option I would love to see this one applied. Duplicate bugs (e.g...