Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A Rails plugin for seeding the database with initial application data.

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 generators
Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 tasks
Octocat-spinner-32 MIT-LICENSE
Octocat-spinner-32 README
Octocat-spinner-32 Rakefile
Octocat-spinner-32 init.rb
Octocat-spinner-32 install.rb
Octocat-spinner-32 uninstall.rb

Seeds are like migrations, but for your data. They makes it easy to populate
the database of a Rails application with default data.

There are three methods by which seed data may be generated: create, update,
and create_or_update. Each of these works by specifying a key that's used to
identify a record. In the case of create the key will be used to ensure that
the record doesn't already exist in the database. For update and
create_or_update it's used to locate the record to be updated.

Keys are specified as method calls, with values being passed to the methods as
arguments. For an ID of 1, use id(1). For a state and abbreviation, use
state_and_abbreviation('FL', 'Florida').

Additional attributes may be chained on to the end as a hash of key/value pairs
passed to the attributes method.


class TierSeed < Germinate::Seed
  # create by name
  create do |tier|'Ultra')

  # update by ID and name
  update do |tier|
    tier.id_and_name(1, 'Basic')

  # create or update by ID
  create_or_update do |tier| => 'Standard') => 'Premium')

Rake Task

To seed the database, use the included rake task.

  rake db:seed


There's also a generator called that can be used to generate seed stubs. The
following will generate a seed for the User model with an entry for a user with
a username of "admin."

  ./script/generator seed User username:admin

Copyright (c) 2008 Tyler Hunt, released under the MIT license
Something went wrong with that request. Please try again.