1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| > Item.create(name:"A") TRANSACTION (1.0ms) BEGIN Item Create (1.0ms) INSERT INTO `items` (`name`, `created_at`, `updated_at`) VALUES ('A', '2021-01-16 16:28:31.574474', '2021-01-16 16:28:31.574474') TRANSACTION (1.8ms) COMMIT => #<Item id: 1, name: "A", created_at: "2021-01-16 16:28:31.574474000 +0000", updated_at: "2021-01-16 16:28:31.574474000 +0000">
> Item.create(name:"B") TRANSACTION (1.6ms) BEGIN Item Create (1.2ms) INSERT INTO `items` (`name`, `created_at`, `updated_at`) VALUES ('B', '2021-01-16 16:28:35.344884', '2021-01-16 16:28:35.344884') TRANSACTION (10.3ms) COMMIT => #<Item id: 2, name: "B", created_at: "2021-01-16 16:28:35.344884000 +0000", updated_at: "2021-01-16 16:28:35.344884000 +0000">
> UserTag.create(item:Item.find(1), name: "nice item") Item Load (1.3ms) SELECT `items`.* FROM `items` WHERE `items`.`id` = 1 LIMIT 1 TRANSACTION (1.4ms) BEGIN UserTag Create (1.2ms) INSERT INTO `tags` (`item_id`, `type`, `name`, `created_at`, `updated_at`) VALUES ('1', 'UserTag', 'nice item', '2021-01-16 16:31:08.161727', '2021-01-16 16:31:08.161727') TRANSACTION (2.3ms) COMMIT => #<UserTag id: 1, item_id: "1", type: "UserTag", name: "nice item", comment: nil, created_at: "2021-01-16 16:31:08.161727000 +0000", updated_at: "2021-01-16 16:31:08.161727000 +0000">
> AdminTag.create(item:Item.find(2), name: "best proceeds",comment: "Good prospect" ) Item Load (1.6ms) SELECT `items`.* FROM `items` WHERE `items`.`id` = 2 LIMIT 1 TRANSACTION (1.4ms) BEGIN AdminTag Create (1.1ms) INSERT INTO `tags` (`item_id`, `type`, `name`, `comment`, `created_at`, `updated_at`) VALUES ('2', 'AdminTag', 'best proceeds', 'Good prospect', '2021-01-16 16:35:18.154575', '2021-01-16 16:35:18.154575') TRANSACTION (2.1ms) COMMIT => #<AdminTag id: 2, item_id: "2", type: "AdminTag", name: "best proceeds", comment: "Good prospect", created_at: "2021-01-16 16:35:18.154575000 +0000", updated_at: "2021-01-16 16:35:18.154575000 +0000">
> UserTag.all.to_sql => "SELECT `tags`.* FROM `tags` WHERE `tags`.`type` = 'UserTag'"
irb(main):015:0> Tag.all.to_sql => "SELECT `tags`.* FROM `tags`"
Tag.find(1).class Tag Load (1.5ms) SELECT `tags`.* FROM `tags` WHERE `tags`.`id` = 1 LIMIT 1 => UserTag(id: integer, item_id: string, type: string, name: string, comment: string, created_at: datetime, updated_at: datetime) Tag.find(2).class Tag Load (1.5ms) SELECT `tags`.* FROM `tags` WHERE `tags`.`id` = 2 LIMIT 1 => AdminTag(id: integer, item_id: string, type: string, name: string, comment: string, created_at: datetime, updated_at: datetime)
> UserTag.create(item:Item.find(2), name: "bat item",comment: "fragile" ) Item Load (1.3ms) SELECT `items`.* FROM `items` WHERE `items`.`id` = 2 LIMIT 1 TRANSACTION (1.3ms) BEGIN UserTag Create (1.4ms) INSERT INTO `tags` (`item_id`, `type`, `name`, `comment`, `created_at`, `updated_at`) VALUES ('2', 'UserTag', 'bat item', 'fragile', '2021-01-16 16:48:52.369284', '2021-01-16 16:48:52.369284') TRANSACTION (2.2ms) COMMIT => #<UserTag id: 3, item_id: "2", type: "UserTag", name: "bat item", comment: "fragile", created_at: "2021-01-16 16:48:52.369284000 +0000", updated_at: "2021-01-16 16:48:52.369284000 +0000">
|