This project is archived and is in readonly mode.
:through Associations don't respect default_scope
Reported by Peter Wagenet | March 19th, 2009 @ 02:11 PM | in 3.x
Consider the following case:
class Taggable < ActiveRecord::Base
has_many :taggings
has_many :tags, :through => :taggings
end
class Tagging < ActiveRecord::Base
belongs_to :taggable
belongs_to :tag
default_scope :conditions => { :enabled => true }
end
class Tag < ActiveRecord::Base
belongs_to :tagging
end
Tag.first.tags will entirely ignore the default_scope on Tagging.
I've included a patch which depends on other patch over at http://rails.lighthouseapp.com/p...
Comments and changes to this ticket
-
Jon Leighton December 12th, 2010 @ 05:06 PM
- Assigned user set to Aaron Patterson
- Importance changed from to
I can confirm this is an issue. I've attached an up-to-date patch which fixes it with test cases.
-
Aaron Patterson December 15th, 2010 @ 07:19 PM
- State changed from new to resolved
Fixed in master. Thanks Jon!
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>