diff options
Diffstat (limited to 'activerecord/lib/active_record/relation.rb')
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 36e8d98298..1c3a1dc53b 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 = ["where", "join", "project", "group", "order", "take", "skip"].freeze + CLAUSES_METHODS = ["project", "group", "order", "take", "skip"].freeze attr_reader :relation, :klass def initialize(klass, table = nil) @@ -27,6 +27,19 @@ module ActiveRecord } end + def join(joins) + @relation = @relation.join(@klass.send(:construct_join, joins, nil)) if !joins.blank? + self + end + + def where(conditions) + if !conditions.blank? + conditions = @klass.send(:merge_conditions, conditions) if [String, Hash, Array].include?(conditions.class) + @relation = @relation.where(conditions) + end + self + end + private def method_missing(method, *args, &block) if @relation.respond_to?(method) |