You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We will be using Git a lot, and you should use it too not just for the purpose of this tutorial but for every single project.
76
76
77
-
* sous Mac OS: `$ brew install git`
78
-
* sous Linux: `$ sudo apt-get install git`
77
+
* on Mac OS: `$ brew install git`
78
+
* on Linux: `$ sudo apt-get install git`
79
79
80
80
=== Ruby
81
81
@@ -350,15 +350,15 @@ The next step is to ignore some files that we don’t want to track, so your `.g
350
350
/config/master.key
351
351
----
352
352
353
-
After modifiying the `.gitignore` file we just need to add the files and commit the changes, the commands necessary are shown below:
353
+
After modifying the `.gitignore` file we just need to add the files and commit the changes, the commands necessary are shown below:
354
354
355
355
[source,bash]
356
356
----
357
357
$ git add .
358
358
$ git commit -m "Initial commit"
359
359
----
360
360
361
-
TIP: I have encounter that commiting with a message starting with a present tense verb, describes what the commit does and not what it did, this way when you are exploring the history of the project it is more natural to read and understand(or at least for me). I’ll follow this practice until the end of the tutorial.
361
+
TIP: I have encounter that committing with a message starting with a present tense verb, describes what the commit does and not what it did, this way when you are exploring the history of the project it is more natural to read and understand(or at least for me). I’ll follow this practice until the end of the tutorial.
362
362
363
363
Lastly and as an optional step we setup the GitHub (I’m not going through that in here) project and push our code to the remote server: We first add the remote:
Copy file name to clipboardExpand all lines: en/chapter05-athentification.adoc
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ First things first (and as usual when starting a new chapter) we will create a n
19
19
$ git checkout -b chapter5
20
20
----
21
21
22
-
== Session sans état
22
+
== Stateless session
23
23
24
24
Before we go any further, something must be clear: *an API does not handle sessions*. If you don’t have experience building these kind of applications it might sound a little crazy but stay with me. An API should be stateless which means by definition _is one that provides a response after your request, and then requires no further attention._. Which means no previous or future state is required for the system to work.
Copy file name to clipboardExpand all lines: en/chapter06-user-products.adoc
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -530,7 +530,7 @@ RSpec.describe Api::V1::ProductsController, type: :controller do
530
530
expect(product_response).to have_key(:errors)
531
531
end
532
532
533
-
it 'renders the json errors on whye the user could not be created' do
533
+
it 'renders the json errors on why the user could not be created' do
534
534
product_response = json_response
535
535
expect(product_response[:errors][:price]).to include 'is not a number'
536
536
end
@@ -671,7 +671,7 @@ RSpec.describe Api::V1::ProductsController, type: :controller do
671
671
expect(product_response).to have_key(:errors)
672
672
end
673
673
674
-
it 'renders the json errors on whye the user could not be created' do
674
+
it 'renders the json errors on why the user could not be created' do
675
675
product_response = json_response
676
676
expect(product_response[:errors][:price]).to include 'is not a number'
677
677
end
@@ -875,6 +875,6 @@ $ git commit -m "Updates test environment factory gems to work on development"
875
875
876
876
== Conclusion
877
877
878
-
On the next chapter we will focus on customizing the output from the `user` and `product` models using the active model serializers gem. It will help us to easily filter attributes to display (or handle associations as embebed objects for example).
878
+
On the next chapter we will focus on customizing the output from the `user` and `product` models using the active model serializers gem. It will help us to easily filter attributes to display (or handle associations as embedded objects for example).
879
879
880
880
I hope you have enjoyed this chapter. It is a long one but the code we put together is an excellent base for the core app.
Copy file name to clipboardExpand all lines: en/chapter09-improve-orders.adoc
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -125,7 +125,7 @@ Finished in 0.33759 seconds (files took 3.54 seconds to load)
125
125
8 examples, 0 failures
126
126
----
127
127
128
-
The `build_placements_with_product_ids_and_quantities` will build the placement objects and once we trigger the `save` method for the order everything will be inserted into the database. One last step before commiting this is to update the `orders_controller_spec` along with its implementation.
128
+
The `build_placements_with_product_ids_and_quantities` will build the placement objects and once we trigger the `save` method for the order everything will be inserted into the database. One last step before committing this is to update the `orders_controller_spec` along with its implementation.
129
129
130
130
First we update the `orders_controller_spec` file:
Copy file name to clipboardExpand all lines: en/chapter10-optimization.adoc
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,13 +29,13 @@ As I have been telling you since the beginning of this book, an important and di
29
29
30
30
One of the most applied conventions is most certainly https://jsonapi.org/[JSON:API]. This convention will allow us to approach pagination more serenely in the next section.
31
31
32
-
So https://jsonapi.org/format/#document-structure[documentation de JSON:API] gives us some rules to follow concerning JSON presentation.
32
+
So https://jsonapi.org/format/#document-structure[documentation JSON:API] gives us some rules to follow concerning JSON presentation.
33
33
34
34
So our *document* must follow theses rules:
35
35
36
36
* `data`: which must contains the data we send back
37
37
* `errors` which must contains a table of errors that have occurred
38
-
* `meta` which contains https://jsonapi.org/format/#document-meta[objet meta]
38
+
* `meta` which contains https://jsonapi.org/format/#document-meta[object meta]
39
39
40
40
NOTE: The `data` and `errors` keys must not be present at the same time and this makes sense since if an error occurs we should not be able to make data correct.
41
41
@@ -62,7 +62,7 @@ RSpec.describe Api::V1::UsersController, type: :controller do
62
62
expect(json_response[:email]).to eql @user.email
63
63
end
64
64
65
-
it 'has the product ids as an embeded object' do
65
+
it 'has the product ids as an embedded object' do
66
66
expect(json_response[:product_ids]).to eql []
67
67
end
68
68
end
@@ -83,7 +83,7 @@ RSpec.describe Api::V1::UsersController, type: :controller do
0 commit comments