Skip to content

Instantly share code, notes, and snippets.

@jeffminnear
Created November 10, 2015 19:56
Show Gist options
  • Save jeffminnear/ef29cc2e5a4d270fdacd to your computer and use it in GitHub Desktop.
Save jeffminnear/ef29cc2e5a4d270fdacd to your computer and use it in GitHub Desktop.
----------------------------------------------------------------------- 14:52:12
bloccit Đ-> rails c
Loading development environment (Rails 4.2.4)
[1] pry(main)> cd Post.first
Post Load (0.1ms) SELECT "posts".* FROM "posts" ORDER BY "posts"."id" ASC LIMIT 1
[2] pry(#<Post>):1> whereami
Inside #<Post>.
[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,
[4] pry(#<Post>):1> nesting
Nesting status:
--
0. main (Pry top level)
1. #<Post>
[5] pry(#<Post>):1> self.title.save!("A New Title")
NoMethodError: undefined method `save!' for "First Post":String
from (pry):2:in `__pry__'
[6] pry(#<Post>):1> self.title = ("A New Title")
=> "A New Title"
[7] pry(#<Post>):1> self.title
=> "A New Title"
[8] pry(#<Post>):1> save!
(0.1ms) begin transaction
SQL (0.4ms) UPDATE "posts" SET "title" = ?, "updated_at" = ? WHERE "posts"."id" = ? [["title", "A New Title"], ["updated_at", "2015-11-10 19:54:27.428035"], ["id", 1]]
(1.0ms) commit transaction
=> true
[9] pry(#<Post>):1> self.title
=> "A New Title"
[10] pry(#<Post>):1> self.body = ("A New Body")
=> "A New Body"
[11] pry(#<Post>):1> save!
(0.1ms) begin transaction
SQL (0.3ms) UPDATE "posts" SET "body" = ?, "updated_at" = ? WHERE "posts"."id" = ? [["body", "A New Body"], ["updated_at", "2015-11-10 19:54:55.744744"], ["id", 1]]
(2.3ms) commit transaction
=> true
[12] pry(#<Post>):1> self
=> #<Post:0x007fa286533218
id: 1,
title: "A New Title",
body: "A New Body",
created_at: Tue, 10 Nov 2015 19:25:55 UTC +00:00,
updated_at: Tue, 10 Nov 2015 19:54:55 UTC +00:00>
[13] pry(#<Post>):1>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment