Guest User

Untitled

a guest
Jun 19th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. > date = Time.parse("7AM",Date.parse("2009-01-05"))
  2. => Mon Jan 05 07:00:00 -0800 2009
  3. >> g = Group.new
  4. => #<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>
  5. >> g.position = Position.find_by_abbr "PIC"
  6. => #<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">
  7. >> g
  8. => #<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>
  9. >> g.end_time = date
  10. => Mon Jan 05 07:00:00 -0800 2009
  11. >> g
  12. => #<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>
  13. >> g.save!
  14. => true
  15. >> g
  16. => #<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>
  17. >> g.save!
  18. => true
  19. >> g
  20. => #<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>
  21. >> s = Schedule.find 1
  22. => #<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>
  23. >> s.groups << g
  24. => [#<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>]
  25. >> s.groups.last
  26. => #<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>
  27. >> g2 = Group.find 2
  28. => #<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>
  29.  
  30. ## 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