[RUBY] Summary of what I was pointed out after receiving a code review as a beginner

Introduction

Since I received the code review of the app for the first time and pointed out some points, I will summarize the points that were pointed out with the meaning that I want to be careful from now on. The content pointed out was at the stage of creating the flea market apps.

Code review on REDME

-I used devise but forgot to write a column called encrypted_password.

-There was no description of the uniqueness constraint even though the condition that the e-mail address was unique was set.

-In the sample app, when the user was registered, the surname, first name, surname (Frigana), and first name (Frigana) were divided into small input fields, but the surname and first name were combined.

-The birthday column was not a date type with year, month, and day, but was an integer type because it was just a number.

-The implementation of image was described even though it was not necessary to describe it in REDME because it uses active storage.

-The zip code must be an integer type to include hyphens, but it was a string type.

-When using active hash Data is saved as id, so it must be integer type, but it was string type.

-The phone number must be a string type because it is saved as a character string of numbers.

Code review with new registration / login function

-Validation was not summarized by with_options. It is better to summarize it to improve readability.

-Validation of the character limit with password was trying to be set with maximum even though it was the default setting with devise.

-The path was not described in prefix. It is better to write with prefix to improve readability.

-Forgot to delete unnecessary comment outs. To improve readability.

Code review with the ability to list products

-When setting restrictions with before_action: authenticate_user !, it was described in application_controller.rb.

-The with_options were described separately without nesting.

-When implementing the test code that 300 yen or less cannot be registered, it was better to implement it with the boundary value of 299, but it was implemented with 200.

Code review with product purchase function

-Since @item = Item.find (params [: id]) is common to destroy, edit, update, and show, it was not summarized by before_action even though it improves readability.

-Although all actions are described as resources: items, only: [: index,: new,: create,: show,: edit,: update,: destroy], they are not described together with resources: item. Was it.

-The: user_id and: item_id were not described in the form object. Necessary to ensure that you cannot purchase if you do not have a user ID and product ID.

-The optional test code for the building name "Can be purchased even if the building name is empty" was not implemented. Since the building name is optional, we will implement a test code assuming that there may be users who purchase without entering the building name.

Finally

When I summarized it like this again, I thought that there were many rudimentary mistakes. I want to do my best so that I can draw code efficiently without making the same mistakes.

Recommended Posts

Summary of what I was pointed out after receiving a code review as a beginner
What I pointed out as a reviewer for half a year
Bad habits pointed out in code reviews when Java was a beginner
Summary of what I learned about Spring Boot
Summary of what I learned in Spring Batch
What I was addicted to when developing a Spring Boot application with VS Code
A review of the code used by rails beginners
What impressed me as a beginner in writing Ruby
In Ruby code, I was confused for a moment as "Hash-like but parentheses are arrays?"