Skip to content

Instantly share code, notes, and snippets.

@macedo
Created November 5, 2015 17:38
Show Gist options
  • Save macedo/a2384ab26ecf7742fb8d to your computer and use it in GitHub Desktop.
Save macedo/a2384ab26ecf7742fb8d to your computer and use it in GitHub Desktop.
irb(main):010:0> a = KioskConfiguration.with_computer_id('00-50-E4-00-0E-C6').count
(2.6ms) SELECT COUNT(*) FROM "kiosk_configurations" WHERE "kiosk_configurations"."deleted_at" IS NULL AND "kiosk_configurations"."computer_id" = $1 [["computer_id", "00-50-E4-00-0E-C6"]]
=> 0
irb(main):011:0> KioskConfiguration.all.map &:computer_id
KioskConfiguration Load (3.9ms) SELECT "kiosk_configurations".* FROM "kiosk_configurations" WHERE "kiosk_configurations"."deleted_at" IS NULL
=> ["78-31-c1-cf-fd-12", "00-50-E4-00-0E-AC"]
irb(main):044:0> kc = KioskConfiguration.create computer_id: '00-50-E4-00-0E-C6'
(2.1ms) BEGIN
KioskConfiguration Exists (2.0ms) SELECT 1 AS one FROM "kiosk_configurations" WHERE "kiosk_configurations"."computer_id" = '00-50-E4-00-0E-C6' LIMIT 1
(2.2ms) ROLLBACK
(2.2ms) ROLLBACK
=> #<KioskConfiguration id: nil, bearing: nil, centre_id: "", computer_id: "00-50-E4-00-0E-C6", kiosk_id: nil, languages: [], ui_state: 3, ui_state_changed_at: nil, deleted_at: nil, created_at: nil, updated_at: nil>
irb(main):047:0> kc.errors[:computer_id]
=> ["has already been taken"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment