Named seeds in Rails

Sometimes rake db:seeds is not enough, you need something fine grained, like rake db:populate_companies , in order to achieve that I use this solution

Put this code in your rails application

Then in db/seeds/ you can write a seed file named populate_companies.rb , and thats in. Now from your terminal give rake db:seed:populate_companies and the file would be run as rake task.

Advertisements
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: