Mellon
Mellon

Reputation: 38842

use rake task or migration in my case?

I am using Rails 3.

In one database table, I need to have one instance stored in the DB table when initialize the application, (this instance will permanently be used by the application after the application been initialized).

Should I use rake task or use database migration to store this instance? Which way is better for this purpose?

Upvotes: 0

Views: 136

Answers (1)

Douglas F Shearer
Douglas F Shearer

Reputation: 26488

You should use the db/seeds.rb file, it is specifically designed with this purpose in mind.

Railscasts #179 covers this. http://railscasts.com/episodes/179-seed-data

If you wish to share the same records with your tests then you can write them as fixtures and import them in seed.rb. See the Fixtures section in the Railscast.

Upvotes: 1

Related Questions