Skip to content

Instantly share code, notes, and snippets.

@randalmaile
Last active December 31, 2015 05:19
Show Gist options
  • Save randalmaile/7940522 to your computer and use it in GitHub Desktop.
Save randalmaile/7940522 to your computer and use it in GitHub Desktop.
Bloccit - Seed Data
1. At work, I've heard developers mention "hydration." Is this the process of seeding data in a table?
2. How much and how extensive is the seed data. How can I control how much data is populated?
1. In this checkpoint, you'll install a Gem named Faker to help generate development data automatically.
2. Run: rake db:seed to seed the database w/ some random data.
3. Look at some of your data by running "rails c" and:
a. p = Post.find(3)
b. p.comments.count
@mkwiatkowski
Copy link

  1. I've researched this a bit, and it seem to be Java-speak, that's why I didn't know it. ;) Anyway, it's not the same as seed the database. Seeding is about populating the database with sample data, while hydrating is about loading the data from the database into an object. In Rails, Active Record does that automatically whenever you fetch any record from DB, e.g. using find.
  2. It's totally up to you. Seed file is just a Ruby file that uses your models, so it works just like the rest of your Rails app. But remember about its role: it's just to get the developer started, so a handful of records is usually enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment