DB情報変更
migration(productionのDBを初期化)
rake RAILS_ENV=production migrate VERSION=0
AR_Fixtures
ruby script/plugin install http://topfunky.net/svn/plugins/ar_fixtures
Yaml_Waml
ruby script/plugin install http://yaml-waml.googlecode.com/svn/plugins/yaml_waml
/lib/tasks/db_fixtures_save.rake
#
desc "save fixtures from the current environment's database"
task :"db:fixtures:save" => :environment do
pre_defined = Object.subclasses_of([[ActiveRecord]]::Base)
Dir["app/models/*.rb"].each{ |i|
eval File.basename(i, '.rb').classify
}
(Object.subclasses_of(ActiveRecord::Base) - pre_defined).each{ |klass|
klass.to_fixture
}
end
task :save_fixtures => "db:fixtures:save" # alias
fixture
rake db:fixtures:save
rake db:migrate VERSION=0
(database.ymlを編集)
rake db:migrate
rake db:fixtures:load