Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #6687 from tiegz/3-2-optimizations

ActiveRecord#attributes optimization: minimize objects created
  • Loading branch information...
commit aa2bfd69f86acb7952015dc82ef01d8a36dc6efd 1 parent 066e6c6
@josevalim josevalim authored josevalim committed
Showing with 3 additions and 1 deletion.
  1. +3 −1 activerecord/lib/active_record/attribute_methods.rb
4 activerecord/lib/active_record/attribute_methods.rb
@@ -149,7 +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
- Hash[ { |name, _| [name, read_attribute(name)] }]
+ attrs = {}
+ attribute_names.each { |name| attrs[name] = read_attribute(name) }
+ attrs
# Returns an <tt>#inspect</tt>-like string for the value of the
Please sign in to comment.
Something went wrong with that request. Please try again.