提交 581f12b7 编写于 作者: T Tobias Lütke

removed :piggyback in favor of just allowing :select on :through associations


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3326 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 90099e9d
*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]
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册