Forum: Ruby on Rails Strings symbols and databases

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
on 2007-06-20 10:25
(Received via mailing list)
What is the preferred method of saving a hash with symbols as keys to
the db? I tried to find this addressed in the archives, already, but
came up empty.
Since <%= text_field %> creates hashes with symbols by default, what's
the best way to save them?

It appears ruby sticks yaml in a string field in the db like
"--- :vocabulary" if you save a hash key to db.

Is is good style to do something like this to save a hash or is there
a more preferred way?

    score_hash.each do | key, value |
      score =
      score.result = @result = key.to_s
      score.value = value!

Also, when reconstructing the hash later, is it wise to convert back
to symbols (using intern) or just treat as strings?
This topic is locked and can not be replied to.