Reputation: 191
Changing a symbol to string in ruby
The following works
a = :'title of the book'
a = a.to_s
But while trying to change the key of hash, the above does not work.
Upvotes: 0
Views: 2235
Reputation: 11
In this case, I suggest: Hash.stringify_keys This would convert {:Key => value} to {"Key" => value}
Upvotes: 1
Reputation: 5802
You can use stringify_keys
to change all of your hash's keys into strings.
Upvotes: 2