Skip to content

Instantly share code, notes, and snippets.

@ddollar
Created July 8, 2009 18:02
Show Gist options
  • Select an option

  • Save ddollar/143018 to your computer and use it in GitHub Desktop.

Select an option

Save ddollar/143018 to your computer and use it in GitHub Desktop.
teststringex> Contact.delete_all
Contact Delete all (13.3ms) DELETE FROM "contacts" WHERE 1=1
=> 2
teststringex> Contact.find(:all)
Contact Load (0.2ms) SELECT * FROM "contacts"
=> []
teststringex> contact = Contact.new
=> #<Contact id: nil, name: nil, url: nil, phone: nil, created_at: nil, updated_at: nil>
teststringex> contact.name = "Happy Trails"
=> "Happy Trails"
teststringex> contact.phone = "404-555-1212"
=> "404-555-1212"
teststringex> contact
=> #<Contact id: nil, name: "Happy Trails", url: nil, phone: "404-555-1212", created_at: nil, updated_at: nil>
teststringex> contact.save
Contact Load (0.2ms) SELECT * FROM "contacts" WHERE (url LIKE 'happy-trails%')
Contact Create (0.5ms) INSERT INTO "contacts" ("name", "updated_at", "url", "phone", "created_at") VALUES('Happy Trails', '2009-07-08 18:00:25', 'happy-trails', '404-555-1212', '2009-07-08 18:00:25')
=> true
teststringex> Contact.find(:all)
Contact Load (0.4ms) SELECT * FROM "contacts"
=> [#<Contact id: 7, name: "Happy Trails", url: "happy-trails", phone: "404-555-1212", created_at: "2009-07-08 18:00:25", updated_at: "2009-07-08 18:00:25">]
teststringex> contact2 = Contact.new
=> #<Contact id: nil, name: nil, url: nil, phone: nil, created_at: nil, updated_at: nil>
teststringex> contact2.name = "Happy Trails"
=> "Happy Trails"
teststringex> contact2.phone = "770-555-1212"
=> "770-555-1212"
teststringex> contact2.save
Contact Load (0.4ms) SELECT * FROM "contacts" WHERE (url LIKE 'happy-trails%')
Contact Create (0.4ms) INSERT INTO "contacts" ("name", "updated_at", "url", "phone", "created_at") VALUES('Happy Trails', '2009-07-08 18:00:26', 'happy-trails-1', '770-555-1212', '2009-07-08 18:00:26')
=> true
teststringex> Contact.find(:all)
Contact Load (0.4ms) SELECT * FROM "contacts"
=> [#<Contact id: 7, name: "Happy Trails", url: "happy-trails", phone: "404-555-1212", created_at: "2009-07-08 18:00:25", updated_at: "2009-07-08 18:00:25">, #<Contact id: 8, name: "Happy Trails", url: "happy-trails-1", phone: "770-555-1212", created_at: "2009-07-08 18:00:26", updated_at: "2009-07-08 18:00:26">]
teststringex> contact = Contact.find(:first)
Contact Load (0.4ms) SELECT * FROM "contacts" LIMIT 1
=> #<Contact id: 7, name: "Happy Trails", url: "happy-trails", phone: "404-555-1212", created_at: "2009-07-08 18:00:25", updated_at: "2009-07-08 18:00:25">
teststringex> contact.phone = "404-555-1213"
=> "404-555-1213"
teststringex> contact.save
Contact Load (0.4ms) SELECT * FROM "contacts" WHERE (url LIKE 'happy-trails%' and id != 7)
Contact Update (0.5ms) UPDATE "contacts" SET "phone" = '404-555-1213', "updated_at" = '2009-07-08 18:00:26' WHERE "id" = 7
=> true
teststringex> contact = Contact.find(:first)
Contact Load (0.4ms) SELECT * FROM "contacts" LIMIT 1
=> #<Contact id: 7, name: "Happy Trails", url: "happy-trails", phone: "404-555-1213", created_at: "2009-07-08 18:00:25", updated_at: "2009-07-08 18:00:26">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment