diff options
author | Emilio Tagua <miloops@gmail.com> | 2010-03-23 12:56:35 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2010-03-25 15:47:06 -0300 |
commit | fc2e25734a175641595db9612d3fb5371cb8aa2c (patch) | |
tree | 1ab07ad36a4886821de3cd93c3fa81cb9ce15659 | |
parent | 90a4709601873583d32c422c3a6422ef56bbc81b (diff) | |
download | rails-fc2e25734a175641595db9612d3fb5371cb8aa2c.tar.gz rails-fc2e25734a175641595db9612d3fb5371cb8aa2c.tar.bz2 rails-fc2e25734a175641595db9612d3fb5371cb8aa2c.zip |
Move methods from association to relation finder methods.
-rwxr-xr-x | activerecord/lib/active_record/associations.rb | 9 | ||||
-rw-r--r-- | activerecord/lib/active_record/relation/finder_methods.rb | 13 |
2 files changed, 11 insertions, 11 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index a5179033f2..bff82f960c 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1673,15 +1673,6 @@ module ActiveRecord reflection end - def using_limitable_reflections?(reflections) - reflections.collect(&:collection?).length.zero? - end - - def column_aliases(join_dependency) - join_dependency.joins.collect{|join| join.column_names_with_alias.collect{|column_name, aliased_name| - "#{connection.quote_table_name join.aliased_table_name}.#{connection.quote_column_name column_name} AS #{aliased_name}"}}.flatten.join(", ") - end - def add_association_callbacks(association_name, options) callbacks = %w(before_add after_add before_remove after_remove) callbacks.each do |callback_name| diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index d6d3d66642..c1cce679b6 100644 --- a/activerecord/lib/active_record/relation/finder_methods.rb +++ b/activerecord/lib/active_record/relation/finder_methods.rb @@ -175,7 +175,7 @@ module ActiveRecord end def construct_relation_for_association_find(join_dependency) - relation = except(:includes, :eager_load, :preload, :select).select(@klass.send(:column_aliases, join_dependency)) + relation = except(:includes, :eager_load, :preload, :select).select(column_aliases(join_dependency)) apply_join_dependency(relation, join_dependency) end @@ -184,7 +184,7 @@ module ActiveRecord relation = association.join_relation(relation) end - limitable_reflections = @klass.send(:using_limitable_reflections?, join_dependency.reflections) + limitable_reflections = using_limitable_reflections?(join_dependency.reflections) if !limitable_reflections && relation.limit_value limited_id_condition = construct_limited_ids_condition(relation.except(:select)) @@ -311,5 +311,14 @@ module ActiveRecord end end + def column_aliases(join_dependency) + join_dependency.joins.collect{|join| join.column_names_with_alias.collect{|column_name, aliased_name| + "#{connection.quote_table_name join.aliased_table_name}.#{connection.quote_column_name column_name} AS #{aliased_name}"}}.flatten.join(", ") + end + + def using_limitable_reflections?(reflections) + reflections.collect(&:collection?).length.zero? + end + end end |