Forum: Ruby on Rails Storing & retrieving a serialized hash in the DB is not working.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
6343d4d073c5c9309ffc802b1150f258?d=identicon&s=25 RNHurt (Guest)
on 2009-04-29 23:59
(Received via mailing list)
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
This topic is locked and can not be replied to.