Jonas

0

rails console
Running via Spring preloader in process 61215
Loading development environment (Rails 6.0.3.2)
irb(main):001:0> a = Availability.first
  Availability Load (0.8ms)  SELECT "availabilities".* FROM "availabilities" ORDER BY "availabilities"."id" ASC LIMIT $1  [["LIMIT", 1]]
irb(main):002:0> pp a
#<Availability:0x00007f8b12c472d8
 id: 21,
 user_id: 1,
 starts_at: Sat, 01 Aug 2020 16:00:00 UTC +00:00,
 duration: 2 years, 3 months, and 3 days,
 schedule: nil,
 ends_at: Sun, 10 Aug 2025 06:15:00 UTC +00:00,
 created_at: Mon, 10 Aug 2020 06:16:03 UTC +00:00,
 updated_at: Mon, 10 Aug 2020 14:19:47 UTC +00:00,
 till: nil>
=> #<Availability id: 21, user_id: 1, starts_at: "2020-08-01 16:00:00", duration: 2 years, 3 months, and 3 days, schedule: nil, ends_at: "2025-08-10 06:15:00", created_at: "2020-08-10 06:16:03", updated_at: "2020-08-10 14:19:47", till: nil>
irb(main):003:0> a.duration = 2.years + 3.months + 3.days
irb(main):004:0> a.save!
   (0.2ms)  BEGIN
  User Load (0.9ms)  SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2  [["id", 1], ["LIMIT", 1]]
   (0.3ms)  COMMIT
=> true
irb(main):005:0> pp a.reload
  Availability Load (0.4ms)  SELECT "availabilities".* FROM "availabilities" WHERE "availabilities"."id" = $1 LIMIT $2  [["id", 21], ["LIMIT", 1]]
#<Availability:0x00007f8b12c472d8
 id: 21,
 user_id: 1,
 starts_at: Sat, 01 Aug 2020 16:00:00 UTC +00:00,
 duration: 2 years, 3 months, and 3 days,
 schedule: nil,
 ends_at: Sun, 10 Aug 2025 06:15:00 UTC +00:00,
 created_at: Mon, 10 Aug 2020 06:16:03 UTC +00:00,
 updated_at: Mon, 10 Aug 2020 14:19:47 UTC +00:00,
 till: nil>
=> #<Availability id: 21, user_id: 1, starts_at: "2020-08-01 16:00:00", duration: 2 years, 3 months, and 3 days, schedule: nil, ends_at: "2025-08-10 06:15:00", created_at: "2020-08-10 06:16:03", updated_at: "2020-08-10 14:19:47", till: nil>
irb(main):006:0> a.starts_at + a.duration
=> Fri, 04 Nov 2022 16:00:00 UTC +00:00

  • 0 posts
  • 0 subtopics
  • about 2 months ago by vince