diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 48b14f52cb3cd1bd511433f96aa8aa3e7a8b7f1d..45ef990ddbd85ab0306c175ac3d727cfdba3c811 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* removed :piggyback in favor of just allowing :select on :through associations. [Tobias Luetke] + * made method missing delegation to class methods on relation target work on :through associations. [Tobias Luetke] * made .find() work on :through relations. [Tobias Luetke] diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 8ee6eca15f1247c0de23a52fc859f1291e1f2399..562a2dc6b7c905ea240d965291cd1aa5c2f73890 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -881,7 +881,7 @@ def create_has_many_reflection(association_id, options, &extension) :class_name, :table_name, :foreign_key, :exclusively_dependent, :dependent, :select, :conditions, :include, :order, :group, :limit, :offset, - :as, :through, :piggyback, + :as, :through, :finder_sql, :counter_sql, :before_add, :after_add, :before_remove, :after_remove, :extend diff --git a/activerecord/lib/active_record/associations/has_many_through_association.rb b/activerecord/lib/active_record/associations/has_many_through_association.rb index ea338e4658bd7880418d638a5d60e2415fe14e7d..7233876a2d7b5b91265b169200a49f947dead580 100644 --- a/activerecord/lib/active_record/associations/has_many_through_association.rb +++ b/activerecord/lib/active_record/associations/has_many_through_association.rb @@ -85,11 +85,7 @@ def construct_from end def construct_select - selected = ["#{@reflection.table_name}.*"] - if @reflection.options[:piggyback] - selected += [@reflection.options[:piggyback]].flatten.collect { |field| "#{@owner.class.reflections[@reflection.options[:through]].table_name}.#{field}" } - end - selected.join(', ') + selected = @reflection.options[:select] || "#{@reflection.table_name}.*" end def construct_scope diff --git a/activerecord/test/fixtures/category.rb b/activerecord/test/fixtures/category.rb index d0e0dfb7703578ad5983e1637cb680e7a8b4e80f..9be459a80f8e04a133ba028b4c416ac4f5c5563e 100644 --- a/activerecord/test/fixtures/category.rb +++ b/activerecord/test/fixtures/category.rb @@ -6,7 +6,7 @@ def self.what_are_you end has_many :categorizations - has_many :authors, :through => :categorizations, :piggyback => [:post_id] + has_many :authors, :through => :categorizations, :select => 'authors.*, categorizations.post_id' end class SpecialCategory < Category