Skip to content

Instantly share code, notes, and snippets.

@AdKnob
Created November 6, 2016 22:20
Show Gist options
  • Save AdKnob/c3b21f98c2d96550b84b199f80ead901 to your computer and use it in GitHub Desktop.
Save AdKnob/c3b21f98c2d96550b84b199f80ead901 to your computer and use it in GitHub Desktop.
[2] pry(main)> cd Post.first
Post Load (0.1ms) SELECT "posts".* FROM "posts" ORDER BY "posts"."id" ASC LIMIT 1
[3] pry(#<Post>):1> self.methods.sort
=> [:!,
:!=,
:!~,
:<=>,
:==,
:===,
:=~,
:[],
:[]=,
:__binding__,
:__id__,
:__pry__,
:__send__,
:_commit_callbacks,
:_commit_callbacks=,
:_commit_callbacks?,
:_create_callbacks,
:_create_callbacks=,
:_create_callbacks?,
:_destroy,
:_destroy_callbacks,
:_destroy_callbacks=,
:_destroy_callbacks?,
:_find_callbacks,
:_find_callbacks=,
:_find_callbacks?,
:_initialize_callbacks,
[4] pry(#<Post>):1> nesting
Nesting status:
--
0. main (Pry top level)
1. #<Post>
[5] pry(#<Post>):1> self.title = "My new title"
=> "My new title"
[6] pry(#<Post>):1> self.body = "My new body"
=> "My new body"
[7] pry(#<Post>):1> save!
(0.1ms) begin transaction
SQL (0.7ms) UPDATE "posts" SET "title" = ?, "body" = ?, "updated_at" = ? WHERE "posts"."id" = ? [["title", "My new title"], ["body", "My new body"], ["updated_at", "2016-11-06 22:15:52.895778"], ["id", 1]]
(5.1ms) commit transaction
=> true
[8] pry(#<Post>):1> self
=> #<Post:0x007fb26171e358
id: 1,
title: "My new title",
body: "My new body",
created_at: Sun, 06 Nov 2016 16:05:19 UTC +00:00,
updated_at: Sun, 06 Nov 2016 22:15:52 UTC +00:00>
[9] pry(#<Post>):1> q
NameError: undefined local variable or method `q' for #<Post:0x007fb26171e358>
from /Users/adrianknoblauch/.rvm/gems/ruby-2.3.0/gems/activemodel-4.2.5/lib/active_model/attribute_methods.rb:433:in `method_missing'
[10] pry(#<Post>):1> exit
=> #<Post:0x007fb26171e358
id: 1,
title: "My new title",
body: "My new body",
created_at: Sun, 06 Nov 2016 16:05:19 UTC +00:00,
updated_at: Sun, 06 Nov 2016 22:15:52 UTC +00:00>
[11] pry(main)> exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment