diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index c445ec15dd9f5c1e492599cbfe5817ec52ee4f1a..172026d1507ea60bdd23c332bddbce6a633837ac 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -149,9 +149,9 @@ def attribute_names # Returns a hash of all the attributes with their names as keys and the values of the attributes as values. def attributes - attrs = {} - attribute_names.each { |name| attrs[name] = read_attribute(name) } - attrs + attribute_names.each_with_object({}) { |name, attrs| + attrs[name] = read_attribute(name) + } end # Returns an #inspect-like string for the value of the diff --git a/activerecord/lib/active_record/relation/predicate_builder.rb b/activerecord/lib/active_record/relation/predicate_builder.rb index cb8f9034749adbcb0f07ac6d0eb986ff918f6c8c..a240c137ea38c04275669f3bef196b59fa3a998d 100644 --- a/activerecord/lib/active_record/relation/predicate_builder.rb +++ b/activerecord/lib/active_record/relation/predicate_builder.rb @@ -4,7 +4,7 @@ def self.build_from_hash(engine, attributes, default_table) attributes.map do |column, value| table = default_table - if value.is_a?(Hash) + if value.is_a?(Hash) && !value.empty? table = Arel::Table.new(column, engine) value.map { |k,v| build(table[k.to_sym], v) } else