Fork me on GitHub

strapless by jeffrafter

Simple tasks for bootstrapping the data in your rails application

Inspired by the ar_fixtures plugin and the fixture loading in Rick Olson's mephisto. Most of this was developed while working on Mateme with Baobab Health and Partners in Health.

Getting started

Add strapless to your Gemfile then:

$ bundle install

Now you should have the tasks:

$ rake -T bootstrap
(in /path/to/your/rails/project)
rake db:bootstrap:dump  # Create a set of fixtures from the current database
rake db:bootstrap:load  # Load initial fixtures (from db/data/*.yml) into the current database

If you already have data then you can dump it to the db/data folder:

$ rake db:bootstrap:dump

This will load all of your ActiveRecord::Base models (in your app/models) and generate fixtures for them. Strapless will attempt to use your to_param so that the names are pretty. You can override the fixture_name instance method in your model if you want something custom.

Adding these fixtures to your repository makes a lot of sense, unless you have crazy amounts of data.

When you get ready to load the data in, Strapless will take all of the fixture YAML files in your db/data folder and try to read it in.

Warning: when loading the data from a fixture, any existing data will be deleted from the related table.

$ rake db:bootstrap:load

Now you have some data!

Install

If you are not using bundler just:

On RubyGems:

$ gem install strapless

The tasks should automatically appear in Rails 3. If you are using Rails 2, then you will need to load the tasks manually. In your Rakefile add:

require 'strapless/tasks'

Authors

Jeff Rafter (jeff@socialrange.org)

Contact

Jeff Rafter (jeff@socialrange.org)

Download

You can download this project in either zip or tar formats.

You can also clone the project with Git by running:

$ git clone git://github.com/jeffrafter/strapless