where form meets function

programming & design by paul fedory

where form meets function header image 2

Introducing YamlSeeder

January 21st, 2010 · 1 Comment · Uncategorized

Download the gem here (gemcutter.org)

Visit the GitHub source here (github.com)

I’ve finally created a gem for Ruby on Rails apps. It’s called YamlSeeder, and its at version 0.0.1, naturally.

YamlSeeder takes foxy-fixture-like YAML files and seeds them into your Rails app, using ActiveRecord.

Why I Made It

Originally, I stored all my seed data in YAML fixture files, and loaded them using Fixtures.create_fixtures.  This had the benefit of being easy to work with, and easy to maintain.  The downside was that it directly inserted the fixtures by SQL into the database’s tables.  But I wanted to use the callbacks and validation methods provided by ActiveRecord when seeding.  (For example, I wanted to generate a permalink field when saving using “before_save”.)

I modeled YamlSeeder after Fixtures.create_fixtures in ActiveRecord.  It supports the belongs_to association, but no other – this will come in a future release.

How Do I Get It?

the easiest way is to type:

gem install yaml_seeder

But for more information, download the gem here.  For the current source code, visit my GitHub here.

Tags: ······

1 response so far ↓