诗歌rails之 使用fixtures来装载数据
在Rakefile文件中加入:
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
莫愁前路无知己,天下无人不识君。