Created
January 20, 2018 04:54
-
-
Save aviwarner/05898572755aeca41c1224d6a75e5f4e to your computer and use it in GitHub Desktop.
ORM Assignment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[3] pry(main)> nesting | |
Nesting status: | |
-- | |
0. main (Pry top level) | |
[4] pry(main)> post = Post.first | |
Post Load (0.1ms) SELECT "posts".* FROM "posts" ORDER BY "posts"."id" ASC LIMIT ? [["LIMIT", 1]] | |
=> #<Post:0x007fac892b29f0 | |
id: 1, | |
title: "First Post", | |
body: "This is the first post in our system", | |
created_at: Sat, 20 Jan 2018 04:41:10 UTC +00:00, | |
updated_at: Sat, 20 Jan 2018 04:41:10 UTC +00:00> | |
[5] pry(main)> cd post | |
[6] pry(#<Post>):1> nesting | |
Nesting status: | |
-- | |
0. main (Pry top level) | |
1. #<Post> | |
[7] pry(#<Post>):1> self.to_s | |
=> "#<Post:0x007fac892b29f0>" | |
[8] pry(#<Post>):1> self.title = 'some new title' | |
=> "some new title" | |
[9] pry(#<Post>):1> self.body = 'some new body' | |
=> "some new body" | |
[10] pry(#<Post>):1> self.changes | |
=> {"title"=>["First Post", "some new title"], | |
"body"=>["This is the first post in our system", "some new body"]} | |
[11] pry(#<Post>):1> self.save! | |
(0.1ms) begin transaction | |
SQL (0.6ms) UPDATE "posts" SET "title" = ?, "body" = ?, "updated_at" = ? WHERE "posts"."id" = ? [["title", "some new title"], ["body", "some new body"], ["updated_at", "2018-01-20 04:54:20.137510"], ["id", 1]] | |
(1.3ms) commit transaction | |
=> true | |
[12] pry(#<Post>):1> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment