# Storing & retrieving a serialized hash in the DB is not working

**URL:** <https://www.ruby-forum.com/t/storing-retrieving-a-serialized-hash-in-the-db-is-not-working/166832>\
**Category:** Rails\
**Created:** [April 29, 2009, 11:59pm UTC](https://www.ruby-forum.com/t/storing-retrieving-a-serialized-hash-in-the-db-is-not-working/166832 "2009-04-29T23:59:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![RNHurt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ecae2f/32.png) [@RNHurt](https://www.ruby-forum.com/u/RNHurt)\
**Post date:** [April 29, 2009, 11:59pm UTC](https://www.ruby-forum.com/t/storing-retrieving-a-serialized-hash-in-the-db-is-not-working/166832/1 "2009-04-29T23:59:47Z")

</div>

Hey all,

I am trying to find a way to store an hash of variable size (could be  
3 pairs, could by 8 pairs) in a text field in the database. I have  
the following [simplified] setup:

# model

serialize :content

# controller

[all the normal create, edit, etc. stuf]

# view

\<% form\_for @grading\_scale do |f| %\>  
\<%= f.text\_field ‘content[1][letter]’ %\>  
\<%= f.text\_field ‘content[1][grade]’ %\>  
\<%= f.text\_field ‘content[2][letter]’ %\>  
\<%= f.text\_field ‘content[2][grade]’ %\>  
…  
\<% end %\>

This actually stores the correct data in the database and it even  
shows up in the view when I show \<%= debug @scale %\>. However, no  
matter how hard I try I cannot get it to display the data from the  
database in the text fields. I can change/add new data without  
problems but I can’t show the user the data. What am I doing wrong?

Thanx!  
Richard
