Load fixtures for specific model
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
精彩评论