Permalink
Browse files

Added User and Timeslots to seed

  • Loading branch information...
1 parent 7096f87 commit 40461884a31f73d8accbfdcd123c3fc68a33d01b Joe Peck committed Oct 23, 2012
Showing with 15 additions and 5 deletions.
  1. +15 −5 db/seeds.rb
View
@@ -1,10 +1,20 @@
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
-# Examples:
-#
-# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
-# Mayor.create(name: 'Emanuel', city: cities.first)
sports = EventType.find_or_create_by_name("Sports")
-sports = Event.find_or_create_by_event_type_id(sports.id)
+sports_event = Event.find_or_create_by_event_type_id(sports.id)
+sports_event.timeslots.each &:destroy # to get rid of any timeslots from previous seeding
+
+# 5 timeslots, each starting at 5PM
+now = Time.now
+5.times do |counter|
+ slot_start = now + counter.days
+ starts_at = Time.mktime(slot_start.year, slot_start.month, slot_start.day, 17)
+ sports_event.timeslots.create!(starts_at: starts_at)
+end
+user = User.find_or_initialize_by_email("sports@scimedsolutions.com")
+user.nickname = "Sporty"
+user.password = "sporty"
+user.password_confirmation = "sporty"
+user.save!

0 comments on commit 4046188

Please sign in to comment.