Note that there are some explanatory texts on larger screens.

plurals
  1. POSerialized attributes not coming back as proper objects
    primarykey
    data
    text
    <p>I have a serialized attribute in my model <code>serialize :vertices, Array</code>. All seems OK when using it, but after I reload the console (or on a web request) the serialized array is returned as a string, which is obviously not what I expected. Here is the same procedure in rails console:</p> <pre><code>ruby-1.9.2-p290 :009 &gt; g.vertices = [Vertex.new, Vertex.new] =&gt; [#&lt;Vertex:0x000000036315e8 @neighbours={}, @options={}, @name=nil, @real_name=nil, @teacher=nil, @discipline=nil, @student_group=nil&gt;, #&lt;Vertex:0x00000003631458 @neighbours={}, @options={}, @name=nil, @real_name=nil, @teacher=nil, @discipline=nil, @student_group=nil&gt;] ruby-1.9.2-p290 :010 &gt; g.inspect =&gt; "#&lt;Graph id: 17, vertices: [#&lt;Vertex:0x000000036315e8 @neighbours={}, @options={}, @name=nil, @real_name=nil, @teacher=nil, @discipline=nil, @student_group=nil&gt;, #&lt;Vertex:0x00000003631458 @neighbours={}, @options={}, @name=nil, @real_name=nil, @teacher=nil, @discipline=nil, @student_group=nil&gt;], oriented: true, max_index: 0, trigger_limit: nil, created_at: \"2011-11-01 09:13:40\", updated_at: \"2011-11-01 09:17:30\", name: nil&gt;" ruby-1.9.2-p290 :011 &gt; g.save (0.4ms) UPDATE "graphs" SET "vertices" = '--- - !ruby/object:Vertex neighbours: {} options: {} name: !!null real_name: !!null teacher: !!null discipline: !!null student_group: !!null - !ruby/object:Vertex neighbours: {} options: {} name: !!null real_name: !!null teacher: !!null discipline: !!null student_group: !!null ', "updated_at" = '2011-11-01 09:21:11.516199' WHERE "graphs"."id" = 17 =&gt; true ruby-1.9.2-p290 :012 &gt; g.inspect =&gt; "#&lt;Graph id: 17, vertices: [#&lt;Vertex:0x000000036315e8 @neighbours={}, @options={}, @name=nil, @real_name=nil, @teacher=nil, @discipline=nil, @student_group=nil&gt;, #&lt;Vertex:0x00000003631458 @neighbours={}, @options={}, @name=nil, @real_name=nil, @teacher=nil, @discipline=nil, @student_group=nil&gt;], oriented: true, max_index: 0, trigger_limit: nil, created_at: \"2011-11-01 09:13:40\", updated_at: \"2011-11-01 09:21:11\", name: nil&gt;" ruby-1.9.2-p290 :013 &gt; reload! Reloading... =&gt; true ruby-1.9.2-p290 :014 &gt; g = Graph.last Graph Load (0.1ms) SELECT "graphs".* FROM "graphs" ORDER BY "graphs"."id" DESC LIMIT 1 =&gt; #&lt;Graph id: 17, vertices: "---\n- !ruby/object:Vertex\n neighbours: {}\n option...", oriented: true, max_index: 0, trigger_limit: nil, created_at: "2011-11-01 09:13:40", updated_at: "2011-11-01 09:21:11", name: nil&gt; ruby-1.9.2-p290 :015 &gt; g.vertices.class =&gt; String ruby-1.9.2-p290 :016 &gt; </code></pre> <p>I guess its not deserializing properly (maybe because of my custom classes in the array?) Any tips would be really appreciated. Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload