1
namespace
:
db
do
2 desc " Load seed fixtures (from db/fixtures) into the current environment's database. "
3 task : seed => : environment do
4 require ' active_record/fixtures '
5 Dir . glob (RAILS_ROOT + ' /db/fixtures/*.yml ' ) . each do | file |
6 Fixtures . create_fixtures( ' db/fixtures ' , File . basename(file , ' .* ' ))
7 end
8 end
9 end
开发环境下使用:rake db:seed 来装载使用到的数据
2 desc " Load seed fixtures (from db/fixtures) into the current environment's database. "
3 task : seed => : environment do
4 require ' active_record/fixtures '
5 Dir . glob (RAILS_ROOT + ' /db/fixtures/*.yml ' ) . each do | file |
6 Fixtures . create_fixtures( ' db/fixtures ' , File . basename(file , ' .* ' ))
7 end
8 end
9 end