Skip to content

Commit

Permalink
Added seed data. I know it's not nice to do it via the migrations, bu…
Browse files Browse the repository at this point in the history
…t it's just an example here. Normally you want to use a seed plugin or wait for Rails 3 built-in seed support. :-)
  • Loading branch information
Steffen Hiller committed Jun 4, 2009
1 parent 0920af6 commit be81b0d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions db/migrate/20090604124226_users_seed_data.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class UsersSeedData < ActiveRecord::Migration
def self.up
# sample data from the php example
seed = [{ 'id' => 1, 'first' => "Fred", 'last' => 'Flintstone', 'email' => 'fred@flintstone.com' },
{ 'id' => 2, 'first' => "Wilma", 'last' => 'Flintstone', 'email' => 'wilma@flintstone.com' },
{ 'id' => 3, 'first' => "Pebbles", 'last' => 'Flintstone', 'email' => 'pebbles@flintstone.com' },
{ 'id' => 4, 'first' => "Barney", 'last' => 'Rubble', 'email' => 'barney@rubble.com' },
{ 'id' => 5, 'first' => "Betty", 'last' => 'Rubble', 'email' => 'betty@rubble.com' },
{ 'id' => 6, 'first' => "BamBam", 'last' => 'Rubble', 'email' => 'bambam@rubble.com' }]

seed.each do |data|
User.create! data
end
end

def self.down
User.delete_all
end
end

0 comments on commit be81b0d

Please sign in to comment.