诗歌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 来装载使用到的数据
posted @ 2009-07-21 12:11  麦飞  阅读(201)  评论(0编辑  收藏  举报