Skip to content
This repository was archived by the owner on Jan 24, 2018. It is now read-only.

Fake data (faker gem)

acramatte edited this page Jan 10, 2012 · 2 revisions

Instead of always having to create fake users data to help us in our development, we decided to make use of the Faker gem.

This gem allows us to easily generate, among other things, names, emails and random text which is exactly what we need for our web application.

Install :

Simply do :

gem install faker

Use :

We created a sample_data.rake file in the /lib/tasks folder of our application and told this file that it requires the faker gem. We then defined several methods to create bands, users, posts and relations between bands and users.

To populate the database do :

rake db:populate

*Note that it would have been possible to fill the database with fixtures (see this how to) but we found the faker gem more convenient.

Clone this wiki locally