K
Keith Tom
Hi all,
I ran into some trouble w/ a model that has a nested hash attribute and
need some help.
Here are the details:
- migration has "t.column :attribute, :text"
- model has "serialize :attribute, Hash"
Now when I put a plain (non-nested) hash in my fixtures, this attribute
works fine; I run the tests, it unserializes, and am very happy.
When I put something like this in the fixture:
attribute: "<%= { :date => 1, :items => 2}.to_yaml %>"
I run the tests and get:
Exception: attribute was supposed to be a Hash, but was a String
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4.5618/lib/active_record/base.rb:1951:in
`unserialize_attribute'
I checked and the string that is being returned is:
--- :items: 2 :date: 1
I did some googling and was under the impression nested hashes are
okay... I get the feeling that is wrong...
Thanks in advance guys!
Keith
I ran into some trouble w/ a model that has a nested hash attribute and
need some help.
Here are the details:
- migration has "t.column :attribute, :text"
- model has "serialize :attribute, Hash"
Now when I put a plain (non-nested) hash in my fixtures, this attribute
works fine; I run the tests, it unserializes, and am very happy.
When I put something like this in the fixture:
attribute: "<%= { :date => 1, :items => 2}.to_yaml %>"
I run the tests and get:
Exception: attribute was supposed to be a Hash, but was a String
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4.5618/lib/active_record/base.rb:1951:in
`unserialize_attribute'
I checked and the string that is being returned is:
--- :items: 2 :date: 1
I did some googling and was under the impression nested hashes are
okay... I get the feeling that is wrong...
Thanks in advance guys!
Keith