开发者

Load fixtures for specific model

开发者 https://www.devze.com 2023-03-07 05:44 出处:网络
For automated testing, RSpe开发者_高级运维c and FactoryGirl are used. Frequently, I need to manually play with my application. So, i need a convenient way to populate database with some data.

For automated testing, RSpe开发者_高级运维c and FactoryGirl are used.

Frequently, I need to manually play with my application. So, i need a convenient way to populate database with some data.

The most convenient way to do it - is fixtures, because they handling relationships between models very well.

I know, that i can load fixtures via rake db:fixtures:load command, but sometimes i need to populate only specific models (say, only customers --> orders --> products)

I'm looking for a command, like this:

rake db:fixtures:load --models=customers,orders,products


You can use:

rake db:fixtures:load FIXTURES=customers,orders,products


What about using the seed command?

rake db:seed

Here's a railscast explaining it in detail:

http://railscasts.com/episodes/179-seed-data

http://asciicasts.com/episodes/179-seed-data

0

精彩评论

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