Best Practice:: Filling Models With Data

Use a Rake task.

In Lib/tasks, make this file


In that file, put this code:

namespace :db do

desc “Boostrap my database with default data”
task :import => :environment do

User.create :login => "admin", :password=>"admin", :password_confirmation=>"admin", email=>""

other cool ruby code goes here



Then, as part of your deployment,

rake RAILS_ENV=“production” db:import

(make that part of your deployment recipe if you wish!)

Hope that helps!