From 5c5059c069a0aa558972e96dfa3d99f371117e55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Intriago?= <46511735+ForerunnerG34@users.noreply.github.com> Date: Fri, 28 May 2021 02:51:51 -0500 Subject: [PATCH 1/5] Update chapter03-presenting-users.adoc Fix: Use correct password_digest field in test code. Fix: Typo. --- rails6/en/chapter03-presenting-users.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rails6/en/chapter03-presenting-users.adoc b/rails6/en/chapter03-presenting-users.adoc index f13e5fe..00fd380 100644 --- a/rails6/en/chapter03-presenting-users.adoc +++ b/rails6/en/chapter03-presenting-users.adoc @@ -183,7 +183,7 @@ end ---- # ... test 'user with invalid email should be invalid' do - user = User.new(email: 'test', password: 'test') + user = User.new(email: 'test', password_digest: 'test') assert_not user.valid? end ---- @@ -249,7 +249,7 @@ gem "bcrypt", "~> 3.1" NOTE: Version 3.1 of bcrypt is the current version at the time of writing. It may therefore vary for your case. -Active Record offers us a method https://github.com/rails/rails/blob/6-0-stable/activemodel/lib/active_model/secure_password.rb#L61[`ActiveModel::SecurePassword::has_secure_password`] that will interface with Bcrypt and hack the password for us very easily. +Active Record offers us a method https://github.com/rails/rails/blob/6-0-stable/activemodel/lib/active_model/secure_password.rb#L61[`ActiveModel::SecurePassword::has_secure_password`] that will interface with Bcrypt and hash the password for us very easily. [source,ruby] .app/models/user.rb From a9ba25ae654afe5f923a430ebd9e316732dd0d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Intriago?= <46511735+ForerunnerG34@users.noreply.github.com> Date: Fri, 28 May 2021 13:03:11 -0500 Subject: [PATCH 2/5] Update chapter03-presenting-users.adoc Fix: Commit message for update action. --- rails6/en/chapter03-presenting-users.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rails6/en/chapter03-presenting-users.adoc b/rails6/en/chapter03-presenting-users.adoc index 00fd380..704a0d8 100644 --- a/rails6/en/chapter03-presenting-users.adoc +++ b/rails6/en/chapter03-presenting-users.adoc @@ -614,7 +614,7 @@ We do a commit Since everything works: [source,bash] ---- -$ git commit -am "Adds update action the users controller" +$ git commit -am "Adds update action to the users controller" ---- === Delete the user From fe336506c54826c75639b91064fd7522d68ed8b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Intriago?= <46511735+ForerunnerG34@users.noreply.github.com> Date: Sun, 13 Jun 2021 21:28:58 -0500 Subject: [PATCH 3/5] Fix casing in create Order model statement --- rails6/en/chapter07-placing-orders.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rails6/en/chapter07-placing-orders.adoc b/rails6/en/chapter07-placing-orders.adoc index 3b87dd5..aed354f 100644 --- a/rails6/en/chapter07-placing-orders.adoc +++ b/rails6/en/chapter07-placing-orders.adoc @@ -31,7 +31,7 @@ Let’s start by creating the older model with a special form: [source,bash] ---- -$ rails generate model order user:belongs_to total:decimal +$ rails generate model Order user:belongs_to total:decimal ---- The command above will generate the order model, but I’m taking advantage of the `belongs_to` column type to create the corresponding foreign key for the order to belong to a user. It also adds the `belongs_to` association into the order model. Let’s migrate the database. From dc18e544307e324f8d4c72fd5ef4108b83cdc6be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Intriago?= <46511735+ForerunnerG34@users.noreply.github.com> Date: Sun, 13 Jun 2021 21:31:25 -0500 Subject: [PATCH 4/5] Remove duplicated question from answers. --- rails6/en/chapter06-improve-json.adoc | 5 ----- 1 file changed, 5 deletions(-) diff --git a/rails6/en/chapter06-improve-json.adoc b/rails6/en/chapter06-improve-json.adoc index b4ea64d..5c4ffaa 100644 --- a/rails6/en/chapter06-improve-json.adoc +++ b/rails6/en/chapter06-improve-json.adoc @@ -1099,11 +1099,6 @@ Which following snippet is a valid JSON:API response?:: With product's user into ---- + -What is the purpose of `Hash#dig` method?:: - . Get a nested element safer. - . Get a nested element and load Active Record relations if needed. - . Add a nested element safer. - What is the purpose of `Hash#dig` method?:: Get a nested element safer. It is a Ruby method allowing you to retrieve elements in a nested `Hash` by avoiding errors if an element is not present. How do you include user information in a JSON:API output of a product?:: From 8c6f89b79c8db8cee29c8efd9ef3ed23c2aa0358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Intriago?= <46511735+ForerunnerG34@users.noreply.github.com> Date: Sun, 13 Jun 2021 23:06:18 -0500 Subject: [PATCH 5/5] Expose order model, not user model. --- rails6/en/chapter07-placing-orders.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rails6/en/chapter07-placing-orders.adoc b/rails6/en/chapter07-placing-orders.adoc index aed354f..c4f3384 100644 --- a/rails6/en/chapter07-placing-orders.adoc +++ b/rails6/en/chapter07-placing-orders.adoc @@ -166,7 +166,7 @@ $ git add . && git commit -m "Associates products and orders with a placements m ---- -== Expose the user model +== Expose the order model It is now time to prepare the order controller to expose the right orders. If you remember the previous chapters where https://github.com/jsonapi-serializer/jsonapi-serializer[jsonapi-serializer] was used, you should remember that it was straightforward.