Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
*.toc
_minted-api-on-rails
build
.DS_Store
2 changes: 1 addition & 1 deletion rails6/en/chapter02-api.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ This way we can namespace our api into different versions very easily, now we ju
Rails.application.routes.draw do
# Api definition
namespace :api, defaults: { format: :json } do
namespace: :v1 do
namespace :v1 do
# We are going to list our resources here
end
end
Expand Down
6 changes: 3 additions & 3 deletions rails6/en/chapter03-presenting-users.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ end

* The password must be present when creating.
* The password length must be less than or equal to 72 bytes.
* the confirmation of the password using the attribute `password_confirmation` (if sent)
* The confirmation of the password using the attribute `password_confirmation` (if sent)

In addition, this method will add a `User#password` attribute that will be automatically hashed and saved in the `User#password_digest` attribute.

Expand Down Expand Up @@ -354,7 +354,7 @@ end
Then simply add the action to our controller. It is extremely simple:

[source,ruby]
.app/controllers/api/v1/users\_controller.rb
.app/controllers/api/v1/users_controller.rb
----
class Api::V1::UsersController < ApplicationController
# GET /users/1
Expand Down Expand Up @@ -404,7 +404,7 @@ As usual, after adding one of the features we are satisfied with, we make a _com

[source,bash]
----
$ git add . && git commit -m "Adds show action the users controller"
$ git add . && git commit -m "Adds show action to the users controller"
----

=== Test our resource with cURL
Expand Down
7 changes: 4 additions & 3 deletions rails6/en/chapter04-athentification.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ I know that's a lot of code but we're going to review it together.

There you go. In order to load the file into our application, you must specify the `lib` folder in the list of Ruby on Rails _autoload_s. To do this, add the following configuration to the `application.rb` file:

.lib/json_web_token.rb
.config/application.rb
[source,ruby]
----
# ...
Expand Down Expand Up @@ -450,7 +450,7 @@ We have a route to update the user but there is a problem: anyone can update any

It is now time to update our `users_controller.rb` file to refuse access to certain actions. We will also implement the `current_user` method on the `update` and `destroy` action to ensure that the user who is logged in will only be able to update his data and can only delete (and only) his account.

We will therefore split our test _should update user_ and _should destroy user_ into two tests
We will therefore split our test _should update user_ and _should destroy user_ into two tests.

Let's start by updating the _should update user_ test.

Expand All @@ -475,7 +475,7 @@ class Api::V1::UsersControllerTest < ActionDispatch::IntegrationTest
end
----

You can see now we have to add a header _Authorization_ for the user's modification action. We want to receive a _forbidden_ response if we don't .
You can see now we have to add a header _Authorization_ for the user's modification action. We want to receive a _forbidden_ response if we don't.

We can imagine about the same thing for the test _should forbid destroy user_:

Expand Down Expand Up @@ -543,6 +543,7 @@ There you go! The implementation is really simple. It is therefore time to _comm

[source,bash]
----
$ git commit -am "Restrict actions for unauthorized users"
$ git checkout master
$ git merge chapter04
----
Expand Down