v2.3.8 - Show latest stable - 2 notes - Class: HashWithIndifferentAccess
symbolize_keys!() public

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Show source
Register or log in to add new notes.
June 29, 2008
6 thanks

Turns hash keys into symbols

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.

October 30, 2008
2 thanks

Does very litle

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”.