# Demonstration; demo or die

**URL:** <https://www.ruby-forum.com/t/demonstration-demo-or-die/117622>\
**Category:** Rails\
**Created:** [October 18, 2007, 6:42pm UTC](https://www.ruby-forum.com/t/demonstration-demo-or-die/117622 "2007-10-18T18:42:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![banry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/898d66/32.png) [@banry](https://www.ruby-forum.com/u/banry)\
**Post date:** [October 18, 2007, 6:42pm UTC](https://www.ruby-forum.com/t/demonstration-demo-or-die/117622/1 "2007-10-18T18:42:40Z")

</div>

I like these fixtures files I am writing for the testing units. That  
makes a lot of sense to me.

As I get to about the 60% point in my little web-application-to-learn-  
rails, I have started to do little demonstrations. “See, you login  
here, then you look for a student, assign them to your ‘parent’ sheet,  
then put in your emergency contacts like this…” and I realize that  
what I REALLY want (what I really really want) is to be able to reset  
the database to a demonstration position. So I don’t have to delete  
associations and start from a blank page again to show it off.

The testing stuff is a little opaque to me.

If I wrote a bunch of fixture files, is there a simple way to say,  
“Dump the records out of the tables in the db, load these in for the  
demonstration…” or should I just start writing a script that empties  
the tables and reads in the YAML files manually?

I’d hate to be duplicating work that’s already sitting in this clever,  
shiny machine I’ve installed on my iMac.

Thanks,  
–Colin

---

<div class="post-metadata">

**Author:** ![banry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/898d66/32.png) [@banry](https://www.ruby-forum.com/u/banry)\
**Post date:** [October 18, 2007, 7:03pm UTC](https://www.ruby-forum.com/t/demonstration-demo-or-die/117622/2 "2007-10-18T19:03:09Z")

</div>

Depending on your database, sure. I often take my production database  
and bring it over to my development machine, especially when something  
is broken and I want to fix it.

With postgresql, I do:

pg\_dump eq2guild\_development \> production-20071018.sql  
svn add production-20071018.sql

and then on my development machine:

svn up  
dropdb eq2guild\_development  
createdb -E utf8 eq2guild\_development  
psql -q eq2guild\_development \< production-20071018.sql

I suspect you could write a Ruby script that would take all the active  
record entries and write a yaml file. After all, Toon.find(1).to\_yaml  
will even produce pretty good code for it.  
I suspect there are ways to load yaml fixtures into a ‘demo’ database  
– in fact, is there any reason you can’t have a demo environment,  
just like production, test, and development?

–Michael

---

<div class="post-metadata">

**Author:** ![banry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/898d66/32.png) [@banry](https://www.ruby-forum.com/u/banry)\
**Post date:** [October 18, 2007, 8:01pm UTC](https://www.ruby-forum.com/t/demonstration-demo-or-die/117622/3 "2007-10-18T20:01:04Z")

</div>

The excellent AR\_Fixtures plugin can be used to dump tables into  
fixtures,and there’s a rake task for loading fixtures back in.

I personally create my own rake task to bootstrap a database for a demo,  
so  
I can keep my fixtures solely for testing.
