Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Rails 3 task to dump (parts) of your database to db/seeds.rb

branch: master

This branch is 0 commits ahead and 0 commits behind master

Merge pull request #2 from Slike9/master

(FIX) Models with namespaced names dump
latest commit 2b5bf74432
kev_the_dev authored September 04, 2012
Octocat-spinner-32 lib Update lib/seed_dumper/fetcher.rb August 28, 2012
Octocat-spinner-32 test renamed files April 05, 2011
Octocat-spinner-32 .gitignore ignore rvmrc September 19, 2011
Octocat-spinner-32 CHANGELOG.rdoc Fixed not loading all the models in the rake task April 19, 2011
Octocat-spinner-32 Gemfile Created a Gemfile. September 15, 2011
Octocat-spinner-32 MIT-LICENSE update notice April 05, 2011
Octocat-spinner-32 README.rdoc update notice April 05, 2011
Octocat-spinner-32 Rakefile Corrected a reference to seed_dump. September 15, 2011
Octocat-spinner-32 seed_dumper.gemspec Made gem rails version agnostic. September 15, 2011
README.rdoc

SeedDumper

Seed dumper is a simple plugin that adds a rake task named db:seed:dump. Forked and simplified from seed_dump. If you require

It allows you to create a db/seeds.rb from your existing data in the database. When there is no data in the database it will generate empty create statements.

It mainly exists for people who are too lazy writing create statements in db/seeds.rb themselves and need something (seed_dump) to dump data from the table(s) into seeds.rb

Example Usage

Dump all data directly to db/seeds.rb:

rake db:seed:dump

Result:

$ cat db/seeds.rb 
# Autogenerated by the db:seed:dump task
# Do not hesitate to tweak this to your needs

products = Product.create([
  { :category_id => 1, :description => "Long Sleeve Shirt", :name => "Long Sleeve Shirt" },
  { :category_id => 3, :description => "Plain White Tee Shirt", :name => "Plain T-Shirt" }
])

users = User.create([
  { :id => 1, :password => "123456", :username => "test_1" },
  { :id => 2, :password => "234567", :username => "tes2" }
])

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don't break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Copyright © 2010 Kevin Edwards, released under the MIT license

Something went wrong with that request. Please try again.