I''m trying to store the current versions of a nested association so I can roll back over time, and I can''t figure out what''s wrong here. Here''s my setter and getter: def serialize_children self.children = ActiveSupport::Base64.encode64(Marshal.dump(self.ads)) end def unserialize_children Marshal.load(ActiveSupport::Base64.decode64(self.children)) end This appears to properly encode the data:>> c = Composition.find(39)=> #<Composition id: 39, name: "help me", campaign_id: 5, created_at: "2011-01-10 03:49:08", updated_at: "2011-01-10 16:34:09", position: 1, children: "", revisable_original_id: nil, revisable_branched_from_id: nil, revisable_number: 5, revisable_name: nil, revisable_type: nil, revisable_current_at: nil, revisable_revised_at: "2011-01-10 04:14:46", revisable_deleted_at: nil, revisable_is_current: true>>> c.serialize_children=> "BAhvOjNBY3RpdmVSZWNvcmQ6OkFzc29jaWF0aW9uczo6SGFzTWFueUFzc29j\naWF0aW9uCzoRQGNvdW50ZXJfc3FsIh4iYWRzIi5jb21wb3NpdGlvbl9pZCA9\nIDM5OhBAZmluZGVyX3NxbEAGOhBAcmVmbGVjdGlvbm86NEFjdGl2ZVJlY29y\nZDo6UmVmbGVjdGlvbjo6QXNzb2NpYXRpb25SZWZsZWN0aW9uDjoQQGNsYXNz\nX25hbWUiB0FkOg1Ab3B0aW9uc3sJOg5kZXBlbmRlbnQ6DGRlc3Ryb3k6DWF1\ndG9zYXZlVDoLZXh0ZW5kWwA6Cm9yZGVyIhFwb3NpdGlvbiBBU0M6FkBwcmlt\nYXJ5X2tleV9uYW1lIhNjb21wb3NpdGlvbl9pZDoLQGtsYXNzYwdBZDoKQG5h\nbWU6CGFkczoQQGNvbGxlY3Rpb25UOhdAcXVvdGVkX3RhYmxlX25hbWUiCiJh\nZHMiOgtAbWFjcm86DWhhc19tYW55OhNAYWN0aXZlX3JlY29yZGMQQ29tcG9z\naXRpb246C0Bvd25lcm86EENvbXBvc2l0aW9uCDoWQGF0dHJpYnV0ZXNfY2Fj\naGV7ADoJQGFkc0AAOhBAYXR0cmlidXRlc3sVIgluYW1lIgxoZWxwIG1lIg1w\nb3NpdGlvbmkGIg9jcmVhdGVkX2F0IhgyMDExLTAxLTEwIDAzOjQ5OjA4IhNy\nZXZpc2FibGVfdHlwZTAiEGNhbXBhaWduX2lkaQoiD3VwZGF0ZWRfYXQiGDIw\nMTEtMDEtMTAgMTY6MzQ6MDkiH3JldmlzYWJsZV9icmFuY2hlZF9mcm9tX2lk\nMCIVcmV2aXNhYmxlX251bWJlcmkKIgdpZGksIhNyZXZpc2FibGVfbmFtZTAi\nGnJldmlzYWJsZV9vcmlnaW5hbF9pZDAiGXJldmlzYWJsZV9kZWxldGVkX2F0\nMCIZcmV2aXNhYmxlX2N1cnJlbnRfYXQwIhlyZXZpc2FibGVfaXNfY3VycmVu\ndCIGdCINY2hpbGRyZW4iACIZcmV2aXNhYmxlX3JldmlzZWRfYXQiGDIwMTEt\nMDEtMTAgMDQ6MTQ6NDY6DEBsb2FkZWRUOgxAdGFyZ2V0WwA=\n" But no matter what I try to unserialize it, I always get an empty array as the result. Is this because of the association overriding my attempt to set a new array at the same name? I don''t get any errors, but I don''t get any data either. Thanks in advance, Walter -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jan 10, 5:24 pm, Walter Lee Davis <wa...-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote:> But no matter what I try to unserialize it, I always get an empty array as the result. Is this because of the association overriding my attempt to set a new array at the same name? I don''t get any errors, but I don''t get any data either. >Is there also an association named children ? Fred> Thanks in advance, > > Walter-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jan 10, 2011, at 1:27 PM, Frederick Cheung wrote:> > > On Jan 10, 5:24 pm, Walter Lee Davis <wa...-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote: > >> But no matter what I try to unserialize it, I always get an empty >> array as the result. Is this because of the association overriding >> my attempt to set a new array at the same name? I don''t get any >> errors, but I don''t get any data either. >> > Is there also an association named children ?No, children is just a text column on Composition, and Ad doesn''t have anything like it. I''ve tried the following in console: (paraphrasing because I''m not at my computer) c = Composition.find 39 [big hash of object data] c.children "" (empty string) c.serialize_children (big base64 string) c.children (same big.base64 string) c.unserialize_children [] (empty array) Walter> > Fred >> Thanks in advance, >> >> Walter > > -- > You received this message because you are subscribed to the Google > Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails- > talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > . > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en > . >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 10 Jan 2011, at 18:52, Walter Lee Davis <waltd-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote:> > On Jan 10, 2011, at 1:27 PM, Frederick Cheung wrote: > >> >> >> On Jan 10, 5:24 pm, Walter Lee Davis <wa...-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote: >> >>> But no matter what I try to unserialize it, I always get an empty array as the result. Is this because of the association overriding my attempt to set a new array at the same name? I don''t get any errors, but I don''t get any data either. >>> >> Is there also an association named children ? > > No, children is just a text column on Composition, and Ad doesn''t have anything like it. I''ve tried the following in console: (paraphrasing because I''m not at my computer) >Does it make any difference if you dump self.ads.to_a instead of self.ads? Fred> c = Composition.find 39 > [big hash of object data] > c.children > "" (empty string) > c.serialize_children > (big base64 string) > c.children > (same big.base64 string) > c.unserialize_children > [] (empty array) > > Walter > > >> >> Fred >>> Thanks in advance, >>> >>> Walter >> >> -- >> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jan 10, 2:56 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 10 Jan 2011, at 18:52, Walter Lee Davis <wa...-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote: > > > > > On Jan 10, 2011, at 1:27 PM, Frederick Cheung wrote: > > >> On Jan 10, 5:24 pm, Walter Lee Davis <wa...-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote: > > >>> But no matter what I try to unserialize it, I always get an empty array as the result. Is this because of the association overriding my attempt to set a new array at the same name? I don''t get any errors, but I don''t get any data either. > > >> Is there also an association named children ? > > > No, children is just a text column on Composition, and Ad doesn''t have anything like it. I''ve tried the following in console: (paraphrasing because I''m not at my computer) > > Does it make any difference if you dump self.ads.to_a instead of self.ads? > > Fred >Then I get what looks like an empty array in base64 on the input, and on the output. Walter> > > > c = Composition.find 39 > > [big hash of object data] > > c.children > > "" (empty string) > > c.serialize_children > > (big base64 string) > > c.children > > (same big.base64 string) > > c.unserialize_children > > [] (empty array) > > > Walter > > >> Fred > >>> Thanks in advance, > > >>> Walter > > >> -- > >> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org. > >> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > >> For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. > > > -- > > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jan 10, 8:26 pm, Walter Lee Davis <wa...-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote:> On Jan 10, 2:56 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote:> > > > No, children is just a text column on Composition, and Ad doesn''t have anything like it. I''ve tried the following in console: (paraphrasing because I''m not at my computer) > > > Does it make any difference if you dump self.ads.to_a instead of self.ads? > > > Fred > > Then I get what looks like an empty array in base64 on the input, and > on the output.What does the non base64 encoded, dumped version of self.ads look like. What is the value of self.ads ? Fred>> Walter > > > > > > > > c = Composition.find 39 > > > [big hash of object data] > > > c.children > > > "" (empty string) > > > c.serialize_children > > > (big base64 string) > > > c.children > > > (same big.base64 string) > > > c.unserialize_children > > > [] (empty array) > > > > Walter > > > >> Fred > > >>> Thanks in advance, > > > >>> Walter > > > >> -- > > >> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > > >> To post to this group, send email to rubyonrails-talk@googlegroups.com. > > >> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > >> For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. > > > > -- > > > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm. > > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> > > Then I get what looks like an empty array in base64 on the input, and > > on the output. > > What does the non base64 encoded, dumped version of self.ads look > like. What is the value of self.ads ? > > Fred > >Head -> Table Composition 39 didn''t have any children at the time I serialized it. So I got back exactly what I should have. Trying this code again with a different record I get back exactly what I put into it. Thanks for your help. Walter -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.