Project

sampler

0.0
No commit activity in last 3 years
No release in over 3 years
No more foobar! Run your app locally with *real* sample data
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 0
 Project Readme

Sampler

Local development is a lot more fun when your app has some real data to work with. Sampler provides a convention similar to seeds.rb where you set up sample data in db/samples.rb and then run it whenever you want a fresh, pristine set of data to work with.

Installation

Add this line to your application's Gemfile:

gem 'sampler'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sampler

To generate a default samples.rb file and an initializer, run:

$  rails generate sampler:install

This will create db/samples.rb and config/initializers/sampler.rb

Sample data

Add your sample data to db/samples.rb. Say you were writing a grading app, you might want an admin user (Albus Dumbledore), a TA/GSI (Percy Weasley), students (Harry Potter, Ron Weasley, Hermione Granger), terms, classes (Defense Against the Dark Arts), assignments, grades, etc. If you need it to properly run the app and do all the normal things users would do with your app, it's a good candidate to go in your samples.rb.

What isn't a good candidate for samples.rb? Data that you need in production to bootstrap your app should go in seeds.rb. Actual user data probably shouldn't go in samples.rb, nor any sensitive information. Take this opportunity to pour some imagination into your app! Have fun with it, I promise it makes local development and testing way more enjoyable.

Usage

WARNING: The following command will drop your current database and run rake db:setup before running rake db:sample. Only run this command if you're sure there's nothing in your database you want to keep.

$ bundle exec rake db:sample

Contributing

  1. Fork it
  2. Create a feature branch (git checkout -b my-new-feature)
  3. Stage changes (git add -p)
  4. Commit your changes (git commit)
  5. Push to Github (git push -u origin my-new-feature)
  6. Create new Pull Request

RELEASE NOTES

0.0.5 Added 'db:drop' as a prerequisite to 'db:sample'