Protip: Use Your Factories in Development
I’ve been training a new Rails developer recently, and I’ve found it rewarding. His questions are great: without already-built habits, he thinks of ways to do things I never would.
Last week, he said, “I need to test this view with some real data to make sure it looks OK. We have all these factory methods to use in our unit tests. Can we use those in development?” I almost said no, but then I realized it was a pretty great idea.
We’re using FixtureReplacement on this project, but this technique will work with any factories. We opened script/console and typed the following:
require 'fixture_replacement' include FixtureReplacement require RAILS_ROOT + '/db/example_data'
With that, I could use, for example, our create_completed_order method to make a purchased cart with multiple items in it so we could see how the admin interface was looking. It’s no replacement for good testing, but for quick view checks, it’s a pretty cool trick.

Tyrant is a "meta" Rails application designed to run other Rails applications.
Recent Comments
Tony,
I understand and agree that the back-end shouldn’t output code (html code), and only content. The templates (aka views) should do the trick, but instead of having lot’s of if/else conditionals inside the view, you may just output the following content.
No information available
The template would loop in an array and put all the <li>’s inside the <ul>.
I don’t see anything wrong, nor...