Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- > date = Time.parse("7AM",Date.parse("2009-01-05"))
- => Mon Jan 05 07:00:00 -0800 2009
- >> g = Group.new
- => #<Group id: nil, title: nil, start_time: nil, end_time: nil, schedule_id: nil, created_at: nil, updated_at: nil, notes: nil, position_id: nil>
- >> g.position = Position.find_by_abbr "PIC"
- => #<Position id: 1, name: "Person in Charge", abbr: "PIC", created_at: "2009-05-31 05:31:56", updated_at: "2009-05-31 05:31:56">
- >> g
- => #<Group id: nil, title: nil, start_time: nil, end_time: nil, schedule_id: nil, created_at: nil, updated_at: nil, notes: nil, position_id: 1>
- >> g.end_time = date
- => Mon Jan 05 07:00:00 -0800 2009
- >> g
- => #<Group id: nil, title: nil, start_time: nil, end_time: "2009-01-05 07:00:00", schedule_id: nil, created_at: nil, updated_at: nil, notes: nil, position_id: 1>
- >> g.save!
- => true
- >> g
- => #<Group id: 2, title: nil, start_time: nil, end_time: "2009-01-05 07:00:00", schedule_id: nil, created_at: "2009-05-31 06:21:09", updated_at: "2009-05-31 06:21:09", notes: nil, position_id: 1>
- >> g.save!
- => true
- >> g
- => #<Group id: 2, title: nil, start_time: nil, end_time: "2009-01-05 07:00:00", schedule_id: nil, created_at: "2009-05-31 06:21:09", updated_at: "2009-05-31 06:21:09", notes: nil, position_id: 1>
- >> s = Schedule.find 1
- => #<Schedule id: 1, description: nil, date: "2009-05-23", start_time: "2000-01-01 08:00:00", end_time: "2000-01-01 17:00:00", created_at: "2009-05-31 05:54:16", updated_at: "2009-05-31 05:54:16", facility_id: 1, schedule_file_id: nil>
- >> s.groups << g
- => [#<Group id: 1, title: nil, start_time: "2000-01-01 10:00:00", end_time: "2000-01-01 14:00:00", schedule_id: 1, created_at: "2009-05-31 05:55:25", updated_at: "2009-05-31 05:55:30", notes: nil, position_id: 1>, #<Group id: 2, title: nil, start_time: nil, end_time: "2000-01-01 07:00:00", schedule_id: 1, created_at: "2009-05-31 06:21:09", updated_at: "2009-05-31 06:22:49", notes: nil, position_id: 1>]
- >> s.groups.last
- => #<Group id: 2, title: nil, start_time: nil, end_time: "2000-01-01 07:00:00", schedule_id: 1, created_at: "2009-05-31 06:21:09", updated_at: "2009-05-31 06:22:49", notes: nil, position_id: 1>
- >> g2 = Group.find 2
- => #<Group id: 2, title: nil, start_time: nil, end_time: "2000-01-01 07:00:00", schedule_id: 1, created_at: "2009-05-31 06:21:09", updated_at: "2009-05-31 06:22:49", notes: nil, position_id: 1>
- ## times changed for the same record going from s.groups.last and re finding group id 2
Add Comment
Please, Sign In to add comment