Skip to content

Instantly share code, notes, and snippets.

@danman01
Last active September 10, 2017 22:07
Show Gist options
  • Save danman01/44566283a7677ca0850cadafbeef5775 to your computer and use it in GitHub Desktop.
Save danman01/44566283a7677ca0850cadafbeef5775 to your computer and use it in GitHub Desktop.
update_post_fullstack_project.sh
##########
######
###### As a new user with ID 2:
[email protected]: blog_rails-api-template (dk)* $ [email protected] PASSWORD=q123 sh scripts/sign-up.sh
HTTP/1.1 201 Created
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Content-Type: application/json; charset=utf-8
ETag: W/"8f8adc34bdea9f2e01399080f8856357"
Cache-Control: max-age=0, private, must-revalidate
X-Request-Id: cc020890-4f47-47a3-8871-7d2d21006f67
X-Runtime: 0.160936
Vary: Origin
Transfer-Encoding: chunked
{"user":{"id":2,"email":"[email protected]"}}
[email protected]: blog_rails-api-template (dk)* $ [email protected] PASSWORD=q123 sh scripts/sign-in.sh
HTTP/1.1 200 OK
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Content-Type: application/json; charset=utf-8
ETag: W/"c3e577177b30e3ddf9db0e508d7862d1"
Cache-Control: max-age=0, private, must-revalidate
X-Request-Id: 4612dce4-5252-4c43-9e08-67f76e551d33
X-Runtime: 0.113325
Vary: Origin
Transfer-Encoding: chunked
{"user":{"id":2,"email":"[email protected]","token":"BAhJIiViZWEyZGYzOGM5NTk4MmMwMjI5MWU5MjM1Y2RkNTJhZgY6BkVG--dc2ea45be877f9e7ab40fe473fe814e5f339b626","admin":false}}
[email protected]: blog_rails-api-template (dk)* $ ID=1 TOKEN=BAhJIiViZWEyZGYzOGM5NTk4MmMwMjI5MWU5MjM1Y2RkNTJhZgY6BkVG--dc2ea45be877f9e7ab40fe473fe814e5f339b626 sh scripts/update_posts.sh
HTTP/1.1 200 OK
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Content-Type: application/json; charset=utf-8
ETag: W/"e4d8269850b6828a5b8dbd9736e36780"
Cache-Control: max-age=0, private, must-revalidate
X-Request-Id: d0fa72f2-b04f-474a-8952-3430553a92ab
X-Runtime: 0.064905
Vary: Origin
Transfer-Encoding: chunked
[email protected]: blog_rails-api-template (dk)* $ ID=1 TOKEN=BAhJIiViZWEyZGYzOGM5NTk4MmMwMjI5MWU5MjM1Y2RkNTJhZgY6BkVG--dc2ea45be877f9e7ab40fe473fe814e5f339b626 TITLE="new title" CONTENT="new content" sh scripts/update_posts.sh
HTTP/1.1 200 OK
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Content-Type: application/json; charset=utf-8
ETag: W/"fd3f9070b50a2902dcd53c4cb335908b"
Cache-Control: max-age=0, private, must-revalidate
X-Request-Id: 07624b30-37cf-4067-b2a8-a3afb3b64a18
X-Runtime: 0.025511
Vary: Origin
Transfer-Encoding: chunked
{"post":{"id":1,"title":"new title","content":"new content"}}[email protected]: blog_rails-api-template (dk)* $
#############
###### Server log
######
Started POST "/sign-in" for 127.0.0.1 at 2017-09-10 17:57:44 -0400
Processing by UsersController#signin as */*
Parameters: {"credentials"=>{"email"=>"[email protected]", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}}
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."email" = $1 LIMIT $2 [["email", "[email protected]"], ["LIMIT", 1]]
SQL (6.7ms) UPDATE "users" SET "token" = 'bea2df38c95982c02291e9235cdd52af', "updated_at" = '2017-09-10 21:57:44.194159' WHERE "users"."id" = $1 [["id", 2]]
[active_model_serializers] Rendered UserLoginSerializer with ActiveModelSerializers::Adapter::Json (7.39ms)
Completed 200 OK in 110ms (Views: 8.3ms | ActiveRecord: 7.4ms)
Started PATCH "/posts//1" for 127.0.0.1 at 2017-09-10 17:58:10 -0400
Processing by PostsController#update as */*
Parameters: {"post"=>{"title"=>"", "content"=>""}, "id"=>"1"}
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."token" = $1 LIMIT $2 [["token", "bea2df38c95982c02291e9235cdd52af"], ["LIMIT", 1]]
Post Load (0.5ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]]
(0.2ms) BEGIN
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]]
SQL (0.4ms) UPDATE "posts" SET "title" = $1, "content" = $2, "updated_at" = $3 WHERE "posts"."id" = $4 [["title", ""], ["content", ""], ["updated_at", 2017-09-10 21:58:10 UTC], ["id", 1]]
(6.4ms) COMMIT
[active_model_serializers] Rendered PostSerializer with ActiveModelSerializers::Adapter::Json (1.46ms)
Completed 200 OK in 57ms (Views: 4.5ms | ActiveRecord: 14.3ms)
Started PATCH "/posts//1" for 127.0.0.1 at 2017-09-10 17:59:21 -0400
Processing by PostsController#update as */*
Parameters: {"post"=>{"title"=>"new title", "content"=>"new content"}, "id"=>"1"}
User Load (0.8ms) SELECT "users".* FROM "users" WHERE "users"."token" = $1 LIMIT $2 [["token", "bea2df38c95982c02291e9235cdd52af"], ["LIMIT", 1]]
Post Load (0.8ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]]
(0.2ms) BEGIN
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]]
SQL (0.4ms) UPDATE "posts" SET "title" = $1, "content" = $2, "updated_at" = $3 WHERE "posts"."id" = $4 [["title", "new title"], ["content", "new content"], ["updated_at", 2017-09-10 21:59:21 UTC], ["id", 1]]
(6.6ms) COMMIT
[active_model_serializers] Rendered PostSerializer with ActiveModelSerializers::Adapter::Json (0.56ms)
Completed 200 OK in 22ms (Views: 1.5ms | ActiveRecord: 9.1ms)
############
##### Investigating via Rails console
#####
[1] pry(main)> Post.last
Post Load (0.5ms) SELECT "posts".* FROM "posts" ORDER BY "posts"."id" DESC LIMIT $1 [["LIMIT", 1]]
=> #<Post:0x007f940f1dace0 id: 1, title: "", content: "", user_id: 1, created_at: Sun, 10 Sep 2017 21:34:15 UTC +00:00, updated_at: Sun, 10 Sep 2017 21:58:10 UTC +00:00>
[2] pry(main)> Post.last
Post Load (0.7ms) SELECT "posts".* FROM "posts" ORDER BY "posts"."id" DESC LIMIT $1 [["LIMIT", 1]]
=> #<Post:0x007f940f2718e8 id: 1, title: "new title", content: "new content", user_id: 1, created_at: Sun, 10 Sep 2017 21:34:15 UTC +00:00, updated_at: Sun, 10 Sep 2017 21:59:21 UTC +00:00>
[3] pry(main)> User.last
User Load (0.6ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT $1 [["LIMIT", 1]]
=> #<User:0x007f940c0b6ad8
id: 2,
email: "[email protected]",
token: "bea2df38c95982c02291e9235cdd52af",
password_digest: "$2a$10$iUaaUxwjbNV9LiriBqqVmeQdRNzsvofgOY4cv64.rdbysUbIgjJk2",
admin: false,
created_at: Sun, 10 Sep 2017 21:57:35 UTC +00:00,
updated_at: Sun, 10 Sep 2017 21:57:44 UTC +00:00>
############
##### As the admin user with ID 1:
#####
[email protected]: blog_rails-api-template (dk)* $ [email protected] PASSWORD=test sh scripts/sign-in.sh
HTTP/1.1 200 OK
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Content-Type: application/json; charset=utf-8
ETag: W/"cca0dc0e07f97b714853ecd1c0647bb3"
Cache-Control: max-age=0, private, must-revalidate
X-Request-Id: c94a3ccf-9319-4704-9769-8d9cc0018db6
X-Runtime: 0.158562
Vary: Origin
Transfer-Encoding: chunked
{"user":{"id":1,"email":"[email protected]","token":"BAhJIiUxZGNjNTM1ODdkMzAyYjZlYTZhNWE0ZGY1ZDgwY2QzOQY6BkVG--2431a7387d32d49249a3277afddfca152b7e4c79","admin":true}}
[email protected]: blog_rails-api-template (dk)* $ ID=1 TOKEN=BAhJIiUxZGNjNTM1ODdkMzAyYjZlYTZhNWE0ZGY1ZDgwY2QzOQY6BkVG--2431a7387d32d49249a3277afddfca152b7e4c79 TITLE="new title2" CONTENT="new content2" sh scripts/update_posts.sh
HTTP/1.1 200 OK
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Content-Type: application/json; charset=utf-8
ETag: W/"9e6a6c5965fc9de4c71877ab23731c3c"
Cache-Control: max-age=0, private, must-revalidate
X-Request-Id: a788dbaf-6596-4918-ae09-9000d92ab18c
X-Runtime: 0.037594
Vary: Origin
Transfer-Encoding: chunked
{"post":{"id":1,"title":"new title2","content":"new content2"}}[email protected]: blog_rails-api-template (dk)* $
#################
[email protected]: blog_rails-api-template (dk)* $ rails c
Running via Spring preloader in process 40956
Loading development environment (Rails 5.0.1)
[1] pry(main)> Post.last
Post Load (0.6ms) SELECT "posts".* FROM "posts" ORDER BY "posts"."id" DESC LIMIT $1 [["LIMIT", 1]]
=> #<Post:0x007f940f873430 id: 1, title: "new title2", content: "new content2", user_id: 1, created_at: Sun, 10 Sep 2017 21:34:15 UTC +00:00, updated_at: Sun, 10 Sep 2017 22:04:24 UTC +00:00>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment