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
The previous version demonstrates how concerns can help safely move code around, facilitating a better understanding of the different responsibilities in an implementation.
24
+
This version ensures that all controllers only have REST actions.
25
25
26
-
These were the created concerns:
27
-
-`UserRegistrationsConcern`
28
-
-`UserSessionsConcern`
29
-
-`UserPasswordsConcern`
30
-
-`UserTokensConcern`
31
-
-`UserProfilesConcern`
26
+
To accomplish this the `task_items#complete` and `task_items#incomplete` actions were moved to their own controller:
32
27
33
-
However, since the concerns are mixins, we need to ensure that all method names are unique. After all, if any are repeated, they will overwrite each other.
And here is what this version does. It uses the concerns categorization to implement dedicated routes and controllers.
33
+
Beyond this change, concern was created to share code between the `CompleteTaskItemsController,``IncompleteTaskItemsController`, and `TaskItemsController.`
The Rubycritic score increased from `90.34` to `91.34`.
48
+
The Rubycritic score increased from `91.34` to `91.56`.
54
49
55
-
This happened because each controller allowed the isolation of each action and callback and allowed the definition of methods with the same name. (Example: `user_params` instead of `user_registration_params`, `user_session_params`, `user_password_params`...).
50
+
This happened because each cohesion has been increased, and the controllers are more specialized.
56
51
57
-
Another benefit was the routing definition. It became more readable and easier to understand as it was possible to declare them using only default `REST` actions (index, show, new, create, edit, update, destroy).
52
+
But lets be honest, the routes are worse than before. 😅
58
53
59
54
### 🔎 What the next version will have? <!-- omit in toc -->
60
55
61
-
It shows how the restriction of REST actions can enforce cohesion and ensure controllers are responsible for specific contexts/concepts.
56
+
Let's do what DHH taught us over a decade ago: https://jeromedalbert.com/how-dhh-organizes-his-rails-controllers/
0 commit comments