Browse files

change database initialization code

  • Loading branch information...
1 parent b44be65 commit 5ee1d457fe850c33b1b3d1ecbfa52e76ea2fa8da @fortuity committed Sep 20, 2010
Showing with 18 additions and 6 deletions.
  1. +6 −2 README.textile
  2. +6 −2 TUTORIAL.textile
  3. +6 −2 db/seeds.rb
View
8 README.textile
@@ -161,10 +161,14 @@ puts 'New user created: ' << user1.name
user2 = User.create! :name => 'Other User', :email => 'otheruser@test.com', :password => 'please', :password_confirmation => 'please'
puts 'New user created: ' << user2.name
puts 'SETTING UP EXAMPLE SUBDOMAINS'
-subdomain1 = Subdomain.create! :name => 'foo', :user_id => user1.id
+subdomain1 = Subdomain.create! :name => 'foo'
puts 'Created subdomain: ' << subdomain1.name
-subdomain2 = Subdomain.create! :name => 'bar', :user_id => user2.id
+subdomain2 = Subdomain.create! :name => 'bar'
puts 'Created subdomain: ' << subdomain2.name
+user1.subdomains << subdomain1
+user1.save
+user2.subdomains << subdomain2
+user2.save
</pre>
Run the rake task to seed the database:
View
8 TUTORIAL.textile
@@ -439,10 +439,14 @@ puts 'New user created: ' << user1.name
user2 = User.create! :name => 'Other User', :email => 'otheruser@test.com', :password => 'please', :password_confirmation => 'please'
puts 'New user created: ' << user2.name
puts 'SETTING UP EXAMPLE SUBDOMAINS'
-subdomain1 = Subdomain.create! :name => 'foo', :user_id => user1.id
+subdomain1 = Subdomain.create! :name => 'foo'
puts 'Created subdomain: ' << subdomain1.name
-subdomain2 = Subdomain.create! :name => 'bar', :user_id => user2.id
+subdomain2 = Subdomain.create! :name => 'bar'
puts 'Created subdomain: ' << subdomain2.name
+user1.subdomains << subdomain1
+user1.save
+user2.subdomains << subdomain2
+user2.save
</pre>
Run the rake task to seed the database:
View
8 db/seeds.rb
@@ -11,7 +11,11 @@
user2 = User.create! :name => 'Other User', :email => 'otheruser@test.com', :password => 'please', :password_confirmation => 'please'
puts 'New user created: ' << user2.name
puts 'SETTING UP EXAMPLE SUBDOMAINS'
-subdomain1 = Subdomain.create! :name => 'foo', :user_id => user1.id
+subdomain1 = Subdomain.create! :name => 'foo'
puts 'Created subdomain: ' << subdomain1.name
-subdomain2 = Subdomain.create! :name => 'bar', :user_id => user2.id
+subdomain2 = Subdomain.create! :name => 'bar'
puts 'Created subdomain: ' << subdomain2.name
+user1.subdomains << subdomain1
+user1.save
+user2.subdomains << subdomain2
+user2.save

0 comments on commit 5ee1d45

Please sign in to comment.