method

symbolize_keys!

symbolize_keys!()
public

No documentation available.

# File activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 106
  def symbolize_keys!; self end

2Notes

Turns hash keys into symbols

aevernon · Jun 29, 20086 thanks

This method is part of ActiveSupport, which is a collection of classes and standard library extensions that are useful for Rails.

symbolize_keys! returns a new hash with all keys converted to symbols.

This can be helpful when you have a non-ActiveRecord model and you want your initialize method to take a hash of parameters. If you symbolize the hash, you can extract your parameters regardless of whether initialize received a hash of strings or hash of symbols.

Does very litle

nice64 · Oct 30, 20082 thanks

This method simply returns the hash itself since HashWithIndifferentAccess by definition support symbolized key access. For a (regular rails) Hash there is ActiveSupport::CoreExtensions::Hash::Keys#symbolize_keys! that "Destructively convert all keys to symbols".