# Putting serialized data into fixture

**URL:** <https://www.ruby-forum.com/t/putting-serialized-data-into-fixture/110420>\
**Category:** Rails\
**Created:** [July 26, 2007, 6:32am UTC](https://www.ruby-forum.com/t/putting-serialized-data-into-fixture/110420 "2007-07-26T06:32:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sandrejev](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/779978/32.png) [@sandrejev](https://www.ruby-forum.com/u/sandrejev)\
**Post date:** [July 26, 2007, 6:32am UTC](https://www.ruby-forum.com/t/putting-serialized-data-into-fixture/110420/1 "2007-07-26T06:32:39Z")

</div>

Hi,

I am very fresh to ruby on rails so maybe I am missing something very  
obvious, but anyway. How do I put serialized data into fixture.

I have a class Board which is somewhat a very complex class. It occupies  
more than one line when converted to yaml. Here is the example of what I  
have been doing and what failed so far.

# Board is false

one:  
id: 1  
board: |  
\<%= Board.new.to\_yaml.gsub(/\n/,"\n ")

# Board is false

one:  
id: 1  
board: |  
\<%= Board.new.to\_yaml.gsub(/\n/,"\n ").gsub /$/, " " %\>

For now I stick with manual converting but the serialized object is  
about 100 lines and looks plain ugly. So maybe there is a way to put a  
serialized object in fixture

---

<div class="post-metadata">

**Author:** ![sandrejev](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/779978/32.png) [@sandrejev](https://www.ruby-forum.com/u/sandrejev)\
**Post date:** [September 6, 2007, 6:58pm UTC](https://www.ruby-forum.com/t/putting-serialized-data-into-fixture/110420/2 "2007-09-06T18:58:41Z")

</div>

On Jul 25, 11:32 pm, Sergej Andrejev \<rails-mailing-l…@andreas-  
[s.net](http://s.net)\> wrote:

> ## one: For now I stick with manual converting but the serialized object is about 100 lines and looks plain ugly. So maybe there is a way to put a serialized object infixture
> 
> Posted viahttp://www.ruby-forum.com/.

I haven’t tried with yaml, but with xml, I do like this:

one:  
id: 1  
board: !str ‘\<%= my\_xml %\>’
