Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Remove sort on attributes.keys #5678

merged 1 commit into from

4 participants


Couldn't find a reason the keys are sorted and my preference would be for the hash to be remain in whatever order the attributes hash is.


Hm agreed, no need for sorting at all.

/cc @josevalim


On the other hand, sorting doesn't hurt and gives a nice consistency in the output.


Yeah agreed, it doesn't hurt.. but in the case of consistency, unsure if only attributes sorting would be enough, given it adds methods and associations after the attributes. Anyway, ok to close it so?


@josevalim @carlosantoniodasilva it's not consistent with the underlying data model, nor any other form of ActiveModel/Record introspection methods. You guys are much more familiar with the code base than I, but I think this is the only time the attributes are represented as a sorted set.


@josevalim @carlosantoniodasilva do we have a definition for this pull request?

@carlosantoniodasilva carlosantoniodasilva merged commit f20032f into rails:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 31, 2012
  1. @troyk

    Remove sort on attributes.keys

    troyk committed
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  activemodel/lib/active_model/serialization.rb
2  activemodel/lib/active_model/serialization.rb
@@ -68,7 +68,7 @@ module Serialization
def serializable_hash(options = nil)
options ||= {}
- attribute_names = attributes.keys.sort
+ attribute_names = attributes.keys
if only = options[:only]
attribute_names &= Array(only).map(&:to_s)
elsif except = options[:except]
Something went wrong with that request. Please try again.