Skip to content

Instantly share code, notes, and snippets.

View harssh-sparkway's full-sized avatar

harssh-sparkway

View GitHub Profile
2.0.0p247 :002 > u = User.create!(name:"test")
(0.4ms) BEGIN
SQL (44.1ms) INSERT INTO "users" ("created_at", "name", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["created_at", Mon, 25 Nov 2013 19:35:06 UTC +00:00], ["name", "test"], ["updated_at", Mon, 25 Nov 2013 19:35:06 UTC +00:00]]
(0.8ms) COMMIT
=> #<User id: 1, name: "test", created_at: "2013-11-25 19:35:06", updated_at: "2013-11-25 19:35:06">
2.0.0p247 :003 > u.friends
User Load (2.2ms) SELECT "users".* FROM "users" INNER JOIN "friendships" ON "users"."id" = "friendships"."friend_id" WHERE "friendships"."user_id" = $1 [["user_id", 1]]
=> #<ActiveRecord::Associations::CollectionProxy []>