Skip to content

Commit c43c8c9

Browse files
committed
wip
1 parent b5e3c70 commit c43c8c9

14 files changed

+156
-20
lines changed

.gitmodules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[submodule "rails6/code"]
22
path = rails6/code
3-
url = https://github.com/madeindjs/market_place_api_6.git
3+
url = git@github.com:madeindjs/market_place_api_6.git
44
[submodule "rails5/code"]
55
path = rails5/code
6-
url = https://github.com/madeindjs/market_place_api.git
6+
url = git@github.com:madeindjs/market_place_api.git

rails5/fr/chapter01-introduction.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ end
276276
# ...
277277
----
278278

279-
Ceci, comme vous vous en souvenez peut-être, empêchera l'installation ou l'utilisation de Sqlite lorsque vous déployez votre application chez un fournisseur de serveurs comme Herokufootnote:[Heroku facilite le déploiement de votre application en installant les dépendances sur un serveur en analysant votre _Gemfile_].
279+
Ceci, comme vous vous en souvenez peut-être, empêchera l'installation ou l'utilisation de Sqlite lorsque vous déployez votre application chez un fournisseur de serveurs comme Herokufootnote:[Heroku facilite le déploiement de votre application en installant les dépendances sur un serveur en analysant votre `Gemfile`].
280280

281281
Une fois cette configuration effectuée, il est temps d'exécuter la commande d'installation du paquet pour intégrer les dépendances correspondantes:
282282

rails6/en/chapter01-introduction.adoc

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,54 @@ As we move forward with the tutorial, I'll be using the practices I follow daily
242242
== Conclusion
243243

244244
It's been a long way through this chapter. If you reach here, let me congratulate you and be sure that things will get better from this point. So let's get our hands dirty and start typing some code!
245+
246+
=== Quiz
247+
248+
To make sure that you understood this chapter, try to answer these questions:
249+
250+
Which one is not an editor?::
251+
. iTerm
252+
. VSCode
253+
. VIM
254+
255+
Why we choose SQLite database?::
256+
. for performances, it is the best one
257+
. for simplicity, it only require a library
258+
. for his beautiful name
259+
260+
How to setup Git author informations?::
261+
. `git commit -m "John Doe"`
262+
. `git push -u john doe`
263+
. `git config --global user.name "John Doe"`
264+
265+
How ignore versioning file with Git?::
266+
. with a `.gitignore` file
267+
. `git ignore <file>`
268+
. `git commit -m <file>`
269+
270+
Take your time to answer. Once you resolved these questions, go to the next page to get responses.
271+
272+
<<<
273+
274+
==== Responses
275+
276+
Which one is not an editor?:: iTerm, this is a terminal emulator for MacOS.
277+
278+
Why we choose SQLite database?:: for simplicity, it only require a library. We could choose PostgreSQL but this require more configuration to make it work with Ruby on Rails.
279+
280+
How to setup Git author informations?:: `git config --global user.name "John Doe"`. You can also omit `--global` to set configuration only for your current projet.
281+
282+
How ignore versioning file with Git?:: with a `.gitignore` file. This is a plain text file with one path or file to ignore per line.
283+
284+
=== Go further
285+
286+
If you understood well this chapter and you want to go further I recommend you to try to set up PostgreSQL database and regenerate a brand new project using a new Database:
287+
288+
[source,bash]
289+
----
290+
$ rails new market_place_api --api --database=postgresql
291+
----
292+
293+
This may be a good idea because on production environment you may prefer to have a database server instead of a single file. If you use PostgreSQL in your development workflow, this will allow you to have a more similar environment than your production.
294+
295+
Also, https://guides.rubyonrails.org/active_record_postgresql.html#datatypes[PostgreSQL offers a number of specific datatypes] who may be fit you better.

rails6/en/chapter02-api.adoc

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ We are going to isolate the API controllers under a namespace. With Rails, this
9191
$ mkdir app/controllers/api
9292
----
9393

94-
Then we add that namespace into our _routes.rb_ file:
94+
Then we add that namespace into our `routes.rb` file:
9595

9696
[source,ruby]
9797
.config/routes.rb
@@ -216,3 +216,51 @@ I know it's been a long way, but you made it, don't give up this is just our sma
216216

217217
I'm not covering those in this book since we are trying to learn how to implement this kind of functionality, but it is good to know. By the way, the code up to this point is https://github.com/madeindjs/market_place_api_6/releases/tag/checkpoint_chapter03[here].
218218

219+
220+
=== Quiz
221+
222+
To make sure that you understood this chapter, try to answer these questions:
223+
224+
Which guideline do you must follow in a RESTfull API::
225+
. Follows the standard HTTP Methods such as GET, POST, PUT, DELETE.
226+
. Buy a specific domain which is compliant with RESTFull API
227+
. Use JSON format
228+
229+
Which file correspond to routes in a Rails application::
230+
. `config/routes.rb`
231+
. `app/controller`
232+
. `config/application.rb`
233+
234+
Which Rails feature we used to build our API versioning::
235+
. a namespace like `namespace :v1`
236+
. a new controller
237+
238+
Which HTTP method allow you to updates a collection or member of the resources::
239+
. `POST`
240+
. `GET`
241+
. `PUT`
242+
243+
How did you merge your branch at the end of this chapter::
244+
. I `checkout` on `master` branch then I `merge` branch `chapter02`
245+
. I `merge` branch `master` into `chapter02`
246+
. `git config --global user.name "John Doe"`
247+
248+
Take your time to answer. Once you resolved these questions, go to the next page to get responses.
249+
250+
<<<
251+
252+
==== Responses
253+
254+
Which guideline do you must follow in a RESTfull API:: Follows the standard HTTP methods such as GET, POST, PUT, DELETE. If you forgot what these methods mean, go
255+
256+
Which file correspond to routes in a Rails application:: `config/routes.rb`. This file contains all application's route.
257+
258+
Which Rails feature we used to build our API versioning:: a namespace like `namespace :v1`. Keep in mind that a namespace is a sort of route prefix which allows you to order some endpoint in the same "folder".
259+
260+
Which HTTP method allows you to updates a collection or member of the resources:: `PUT`. `GET` allow you to access a resource and `POST` to create a new resource.
261+
262+
How did you merge your branch at the end of this chapter:: I `checkout` on `master` branch then I `merge` branch `chapter02`.
263+
264+
=== Go further
265+
266+
To go further, I recommend you to use Github or Gitlab to open a Pull Request with your `chapter02` branch. This will allow you to keep a clean history of what you did and modification. You can add a pretty description of why you did these modifications and how you organized your code. Once the pull request seems good, you can merge it.

rails6/en/chapter03-presenting-users.adoc

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ We will start by generating our `User` model. This model will be really simple a
3737
- `email` which will be unique and will allow it to connect to the application
3838
- `password_digest` which will contain the *hashed* version of the password (we will discuss this later in this chapter)
3939

40-
We generate our `User` model using the _generate model_ command provided by Ruby on Rails. It is very easy to use:
40+
We generate our `User` model using the `generate model` command provided by Ruby on Rails. It is very easy to use:
4141

4242
[source,bash]
4343
----
@@ -227,7 +227,7 @@ So we will use the bcrypt gem to *hash* the password.
227227

228228
NOTE: Hash is the process of transforming a character string into _Hash_. This _Hash_ does not allow you to find the original character string. However, we can easily use it to determine if a given character string matches the _hash_ we have stored.
229229

230-
We must first add the Bcrypt gem to the _Gemfile_. We can use the `bundle add` command. This one will:
230+
We must first add the Bcrypt gem to the `Gemfile`. We can use the `bundle add` command. This one will:
231231

232232
1. add the gem to the Gemfile by retrieving the current version
233233
2. launch the command `bundle install` which will install the gem and update the file _Gemfile.lock_ which "locks" the current version of the gem
@@ -239,7 +239,7 @@ Therefore, issue the following command:
239239
$ bundle add bcrypt
240240
----
241241

242-
Once the command is executed, the following line is added at the end of the _Gemfile_:
242+
Once the command is executed, the following line is added at the end of the `Gemfile`:
243243

244244
[source,ruby]
245245
.Gemfile
@@ -284,7 +284,7 @@ You can see that when you call the `User#create!` method, the `password` attribu
284284
ActiveRecord::RecordInvalid (Validation failed: Password confirmation doesn t match Password)
285285
----
286286

287-
Everything is working as planned! Let's now make a _committe_ to keep the history concise:
287+
Everything is working as planned! Let's now make a _commit_ to keep the history concise:
288288

289289
[source,bash]
290290
----
@@ -697,3 +697,40 @@ $ git merge chapter03
697697
== Conclusion
698698

699699
Oh, there you are! Well done! I know it was probably a long time, but don't give up! Make sure you understand each piece of code, things will improve. In the next chapter, we will redesign our tests to make the code more readable and maintainable. Then stay with me!
700+
701+
=== Quiz
702+
703+
To make sure that you understood this chapter, try to answer these questions:
704+
705+
Which code allow you to set an unique constraint on `User#email` in a migration file::
706+
. `t.string :email, null: false`
707+
. `t.string :email, unique: true`
708+
. `t.index :email, unique: true`
709+
710+
How do we create an user in a unit test?::
711+
. add a record in `test/fixtures/users.yml`
712+
. use `Use.create email: 'toto@toto.fr'` inside test
713+
714+
Which statement is not valid?::
715+
. Hash is the process of transforming a character string into _Hash_.
716+
. Hash allow you to find the original character string
717+
. Hash allow you to determine if a given character string matches
718+
719+
Which feature `has_secure_password` no implement:
720+
. The password must be present when creating.
721+
. The password length must be less than or equal to 72 bytes.
722+
. The password must contains at least on letter and one digit
723+
724+
TODO
725+
726+
[source,ruby]
727+
.config/routes.rb
728+
----
729+
Rails.application.routes.draw do
730+
namespace :api, defaults: { format: :json } do
731+
namespace :v1 do
732+
resources :users, only: [:show]
733+
end
734+
end
735+
end
736+
----

rails6/en/chapter04-authentication.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ So let's start by installing it:
8484
$ bundle add jwt
8585
----
8686

87-
Once completed the following line is added to your _Gemfile_:
87+
Once completed the following line is added to your `Gemfile`:
8888

8989
[source,ruby]
9090
----

rails6/en/chapter09-optimization.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ Processing by Api::V1::ProductsController#index as JSON
580580

581581
It is, therefore, unfortunately **very easy** to create an N+1 query. Fortunately, a gem allows us to **alert** when this kind of situation occurs: https://github.com/flyerhzm/bullet[Bullet]. Bullet will notify us (by email, http://growl.info/[growl notification], https://slack.com[Slack], console, etc...) when it finds an N+1 request.
582582

583-
To install it, we add the _gem_ to the _GemFile_
583+
To install it, we add the _gem_ to the `Gemfile`
584584

585585
[source,bash]
586586
----

rails6/es/chapter03-presenting-users.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ Así que vamos a usar la gema bcrypt para *hashear* la contraseña.
228228

229229
NOTE: Hashear es el proceso de transformar un arreglo de caracteres en un _Hash_. Este _Hash_ no te permite encontrar el arreglo de caracteres original. Pero como sea, podemos fácilmente usarlo para encontrar si un arreglo de caracteres dado coincide con el _hash_ que almacenamos.
230230

231-
Primero debemos agregar la gema Bcrypt al _Gemfile_. Podemos usar el comando `bundle add`. Que hará:
231+
Primero debemos agregar la gema Bcrypt al `Gemfile`. Podemos usar el comando `bundle add`. Que hará:
232232

233233
1. añadir la gema al Gemfile recuperando la versión más reciente
234234
2. ejecutar el comando `bundle install` el cual instalará la gema y actualizará el archivo _Gemfile.lock_ "bloqueando" la versión actual de la gema
@@ -240,7 +240,7 @@ Por lo tanto, ejecutamos el siguiente comando:
240240
$ bundle add bcrypt
241241
----
242242

243-
Una vez que el comando es ejecutado, la siguiente línea es añadida al final del _Gemfile_:
243+
Una vez que el comando es ejecutado, la siguiente línea es añadida al final del `Gemfile`:
244244

245245
[source,ruby]
246246
.Gemfile
@@ -575,7 +575,7 @@ Entonces implementamos la acción update en el controlador del usuario y corremo
575575
----
576576
class Api::V1::UsersController < ApplicationController
577577
before_action :set_user, only: %i[show update]
578-
578+
579579
# GET /users/1
580580
def show
581581
render json: @user

rails6/es/chapter04-authentication.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Asi que vamos a comenzar instalándola:
8484
$ bundle add jwt
8585
----
8686

87-
Una vez completada la siguiente línea es añadida a tu _Gemfile_:
87+
Una vez completada la siguiente línea es añadida a tu `Gemfile`:
8888

8989
[source,ruby]
9090
----

0 commit comments

Comments
 (0)