Method: Hash#symbolize_keys

Defined in:
activesupport/lib/active_support/core_ext/hash/keys.rb

#symbolize_keysObject Also known as: to_options

Returns a new hash with all keys converted to symbols, as long as they respond to to_sym.

hash = { 'name' => 'Rob', 'age' => '28' }

hash.symbolize_keys
# => {:name=>"Rob", :age=>"28"}


27
28
29
# File 'activesupport/lib/active_support/core_ext/hash/keys.rb', line 27

def symbolize_keys
  transform_keys { |key| key.to_sym rescue key }
end