This project is archived and is in readonly mode.
has_many :through Doesn't Use Conditions For Creating New Records
-
Josh Susser
- Tag changed from activerecord, has_many_through to activerecord, has_many_through, patch
While it's possible to create sets of conditions where this will work, you can also easily create ones where they don't. Just try an inequality test and you'll see. e.g. ["published_at < ?", 1.year.ago]. I think coming up with a way to do the right thing while avoiding surprises is going to be very difficult.
-
Matt Bauer
I completely agree with you which is why this patch only works when there is a hash provided. This will avoid surprises though I agree it may be to subtle yet.
-
Duncan McKee
+1 — As it is now, the create method on a has_many association does respect conditions as long as they are in hash form, and it is documented as such. The surprise is that, using the example above, post.skimmers.create creates a reader with skimmer==true, while post.impatient_people.<< creates a reader with skimmer==nil.
-
Repository
(from [83c1934003740ed01c618a8943457a0df53e2adb]) Ensure hm:t#create respects source associations hash conditions [#2090 has_many :through Doesn't Use Conditions For Creating New Records state:resolved]
Signed-off-by: Pratik Naik pratiknaik@gmail.com
http://github.com/rails/rails/commit/83c1934003740ed01c618a8943457a... -
Repository
(from [1707cd907fdc14e69ddee7da3909f077c7621bcd]) Ensure hm:t#create respects source associations hash conditions [#2090 has_many :through Doesn't Use Conditions For Creating New Records state:resolved]
Signed-off-by: Pratik Naik pratiknaik@gmail.com
http://github.com/rails/rails/commit/1707cd907fdc14e69ddee7da3909f0...
