diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-08-18 08:18:24 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-08-18 08:18:24 -0300 |
commit | fa8f5c2667fa82feab66aa102993ab4f123d42bc (patch) | |
tree | 65009ae39047d96327af9c1c883a8108d8ba17d3 | |
parent | 08f6af2d5357b82b59f968aa5e926f6c6fd1e2ff (diff) | |
download | rails-fa8f5c2667fa82feab66aa102993ab4f123d42bc.tar.gz rails-fa8f5c2667fa82feab66aa102993ab4f123d42bc.tar.bz2 rails-fa8f5c2667fa82feab66aa102993ab4f123d42bc.zip |
Relation#joins! should know what to join instead of delegating to
construct_join.
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index bbbb1da210..0d43c53d10 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -1,7 +1,7 @@ module ActiveRecord class Relation delegate :delete, :to_sql, :to => :relation - CLAUSES_METHODS = ["project", "where", "group", "order", "take", "skip", "on"].freeze + CLAUSES_METHODS = ["group", "order", "on"].freeze attr_reader :relation, :klass def initialize(klass, table = nil) @@ -31,7 +31,6 @@ module ActiveRecord } end - def select!(selection) @relation = @relation.project(selection) if selection self @@ -47,12 +46,19 @@ module ActiveRecord self end - def joins!(join, join_type = nil) - if !join.blank? - if [String, Hash, Array, Symbol].include?(join.class) - @relation = @relation.join(@klass.send(:construct_join, join, nil)) + def joins!(joins, join_type = nil) + if !joins.blank? + @relation = case joins + when String + @relation.join(joins) + when Hash, Array, Symbol + if @klass.send(:array_of_strings?, joins) + @relation.join(joins.join(' ')) + else + @relation.join(@klass.send(:build_association_joins, joins)) + end else - @relation = @relation.join(join, join_type) + @relation.join(joins, join_type) end end self |