开发者

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 b开发者_运维百科y 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜