Trowel

Loads ActiveRecord seed data from YAML.

Robo-gardener

Installation

Add to your Gemfile and run the bundle command to install it.

 gem 'trowel'

Usage

Simple example

Trowel::Sow.new(Rails.root.join('db/seeds/users.yml').to_s)

This loads data into the User model. The YAML is expected to look something like this:

# users.yml
-
  email: [email protected]
  password: secret
-
  email: [email protected]
  password: secret

Complex example

Callbacks can be triggered in the form of a symbol or lambda, and the class can be passed in as an option.

For example:

Trowel::Sow.new(Rails.root.join('db/seeds/users.yml'),
                :class => Contact,
                :before_save => lambda { |u| u.email.upcase! },
                :after_save => :confirm!)

Development

Questions or problems? Please post them on the issue tracker. You can contribute changes by forking the project and submitting a pull request. You can ensure the tests passing by running bundle and rake.

Copyright (c) 2012 Zubin Henner, released under the MIT license