Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rake db:fixtures:load on factory_girl

I used "rake db:fixtures:load" to insert dummy datas into development db. I start using factory_girl. Are there any way to insert datas in RAILS_ROOT/spec/factories/*.rb to development db?

like image 394
Gill Bates Avatar asked Jan 21 '26 18:01

Gill Bates


1 Answers

Factories are not intended to fill the database. They will generate random data for your object attributes (unless otherwise specified). Hence, it won't fill the development database with defined data.

What you should use here are seeds. More info on:

http://ryandaigle.com/articles/2009/5/13/what-s-new-in-edge-rails-database-seeding and http://rails-bestpractices.com/posts/20-isolating-seed-data

like image 176
jbescoyez Avatar answered Jan 24 '26 14:01

jbescoyez



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!