This project is archived and is in readonly mode.
has_many :through :conditions on join tables are ignored on create
Reported by Pascal Friederich | July 16th, 2008 @ 08:10 PM | in 2.x
When creating a has_many :through association with conditions on the join table, the condition is not beeing set when adding a new entry through the association.
class Group < ActiveRecord::Base
has_many :relations
has_many :special_users, :through => :relations, :source => :user, :conditions => {"relations.type_str" => "special"}
end
class User < ActiveRecord::Base
has_many :permissions
end
class Relation < ActiveRecord::Base
belongs_to :group
belongs_to :user
end
if you add a user through the special_users association, the type_str is set to NULL on the join table.
Comments and changes to this ticket
-
Pascal Friederich July 17th, 2008 @ 02:50 AM
- Tag changed from activerecord, bug to activerecord, bug, patch
i made a patch on has_many_through_association.rb which adds the condition to the join table if a new object is added through the hmt association.
it only does if the value is a string.
The tests did all pass here but iam not a very experienced ruby programmer so please could you check this? maybe i'm totally wrong but at least i tried :)
-
Pascal Friederich July 17th, 2008 @ 02:52 AM
wrong email in patch.. its paukul@gmail.com (if it matters)
here's the right one
-
Pascal Friederich July 20th, 2008 @ 03:55 PM
- no changes were found...
-
Pratik July 20th, 2008 @ 06:35 PM
- State changed from new to incomplete
- Assigned user set to Pratik
Patch is missing tests.
Thanks.
-
CancelProfileIsBroken August 3rd, 2009 @ 03:00 PM
- Tag changed from activerecord, bug, patch to activerecord, bug, bugmash, patch
-
Pascal Friederich August 3rd, 2009 @ 10:56 PM
that feature was already added by mattbauer with commit 83c1934003740ed01c618a8943457a0df53e2adb
-
CancelProfileIsBroken August 3rd, 2009 @ 10:59 PM
- Tag changed from activerecord, bug, bugmash, patch to activerecord, bug, patch
- State changed from incomplete to resolved
Good catch, thanks!
-
Jeff Kreeftmeijer November 7th, 2010 @ 04:53 PM
- Tag changed from activerecord, bug, patch to activerecord bug patch
- Importance changed from to Low
Automatic cleanup of spam.
-
joson April 29th, 2011 @ 09:08 AM
A Replica Breitling is a timepiece of high quality and functionality and you will have all the class, prestige and luxury of a wealthy, successful individual. By choosing from our selection of luxury Replica Watches , you can improve your self-esteem and feel confident to enter new circles of business associates and friends. These Rolex Replicas will surely enhance your style and only you will know the watch you wear did not cost you $1,000's of dollars.
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>