I recommend that you do not embed any new data in the migration. Instead, just modify existing data in migrations.
For input, I recommend using YML. In every Rails project that I configure, I create a fixture catalog in the DB directory. Then I create the YML files for the source data, just as the YML files are used for the test data. Then I add a new task to load data from YML files.
Library / Tasks / db.rake:
namespace :db do desc "This loads the development data." task :seed => :environment do require 'active_record/fixtures' Dir.glob(RAILS_ROOT + '/db/fixtures/*.yml').each do |file| base_name = File.basename(file, '.*') say "Loading #{base_name}..." Fixtures.create_fixtures('db/fixtures', base_name) end end desc "This drops the db, builds the db, and seeds the data." task :reseed => [:environment, 'db:reset', 'db:seed'] end
db / appliances / users.yml:
test: customer_id: 1 name: "Test Guy" email: "test@example.com" hashed_password: "656fc0b1c1d1681840816c68e1640f640c6ded12" salt: "188227600.754087929365988"
Jay Stramel Sep 15 '08 at 17:14 2008-09-15 17:14
source share