1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #4222 from amatsuda/ar_predicate_builder_refactor

refactor AR::PredicateBuilder.build_from_hash
This commit is contained in:
Aaron Patterson 2011-12-28 11:42:29 -08:00
commit 0b61e3f86a

View file

@ -15,8 +15,14 @@ module ActiveRecord
table = Arel::Table.new(table_name, engine)
end
attribute = table[column.to_sym]
build(table[column.to_sym], value)
end
end
predicates.flatten
end
private
def self.build(attribute, value)
case value
when ActiveRecord::Relation
value = value.select(value.klass.arel_table[value.klass.primary_key]) if value.select_values.empty?
@ -54,8 +60,4 @@ module ActiveRecord
end
end
end
predicates.flatten
end
end
end