All right, I posted about this yesterday and I have to believe the problem is not with AR's serialize method but with my particular circumstance.
The two obvious issues are that
(1) I'm serializing a hash of 15 objects that contain seven strings apiece. The objects were Structs, but in the interest of pulling the definition out of a module and putting it in app/models, I've since turned it into a non-AR Class because I thought maybe the issue was that the Struct was defined in a library module.
models/idx_row.rb:
class IdxRow attr_accessor :image_url, :price, :beds, :baths, :sqft, :mls_id, :mls_url
def initialize @image_url = "" @price = "" @beds = "" @baths = "" @sqft = "" @mls_id = "" @mls_url = "" end end
(2) The model I have the serialized attribute on is the Comment class created by acts_as_commentable. The basic class definition is in the plugin, not in app/models. I looked through the code and it looked like the proper way to extend the class was through a module of my own, so I created lib/commentable_extensions.rb and put it there. I added a TEXT column called "feed", and wrote the following:
lib/commentable_extensions.rb:
module CommentableExtensions module Juixe module Acts #:nodoc: module Commentable #:nodoc: module ClassMethods def acts_as_commentable serialize :feed end end end end end end
I've tried a few ways of loading the extension, currently an include in application.rb, and when I load a Comment into c and assign one of my hashes to c.feed, I get the same old SystemStackError when I attempt c.save:
SystemStackError: stack level too deep from c:/ruby/lib/ruby/1.8/yaml/rubytypes.rb:168:in `to_yaml' from c:/ruby/lib/ruby/1.8/yaml.rb:387:in `quick_emit' from c:/ruby/lib/ruby/1.8/yaml/rubytypes.rb:164:in `to_yaml' from c:/ruby/lib/ruby/1.8/yaml/rubytypes.rb:41:in `to_yaml' from c:/ruby/lib/ruby/1.8/yaml/rubytypes.rb:40:in `to_yaml' from c:/ruby/lib/ruby/1.8/yaml/rubytypes.rb:39:in `to_yaml' from c:/ruby/lib/ruby/1.8/yaml.rb:387:in `quick_emit'.....
Though it's possible that my object is simply too complex for #to_yaml's tiny brain, I'm reluctant to think that's the case with what seems to me such a simple data structure. At this point I'm wondering if the problem is the way I'm trying to declare the serialization of :feed. Is there some other place or way I'm supposed to do this?
Thanks.