Things_top
Things_bottom

Tip: Quick and Dirty start to generating fixtures for testing

A quick and dirty way to get you started on getting some of the information out of your database and into a fixtures file. (For testing your Rails applications)

script/runner "puts User.all.to_yaml" >> spec/fixtures/users.yml 

Now there is still a lot that you’ll need to edit out of the file. Such as the “serialised ruby object” declaration at the start of the file, and empty attributes. This isn’t intended to automatically create your fixtures, it’s just a quick tip on an easier way to start.

Tagged as ruby, fixtures and rails

Posted Nov 21st, 2008.