Ruby on Rails 5 quick learning practice guide that can be used in the field Summary

I've learned all the Ruby on Rails 5 quick learning practice guides that can be used in the field, so I see! I made a note of what I thought.



A tool that makes Ruby version control easier. Version control is important because it is necessary to use different versions according to the project in development. The speed of operation and the ease of use of gem management by Bundler are highly evaluated.

Homebrew is convenient for installing rbenv, and Xcode is required to use Homebrew. In other words, install in the order of Xcode-> Homebrew-> rbenv.


Abbreviation for Relational Data Base. A database that manages data in tables and shows relevance in an easy-to-understand manner. It also includes Mysql and Postgresql that I usually use.

__ Asset Pipeline: __

A process that optimizes the written CSS and JavaScript for the browser. In the production environment, assets are concatenated / minimized from the viewpoint of emphasizing processing speed and communication volume, whereas in the devlopment environment, assets are not concatenated / minimized in order to pursue ease of debugging.


    = stylesheet_link_tag    'application', media: 'all'
    = javascript_include_tag 'application'

The browser is loading CSS and JavaScript assets by writing the helper methods stylesheet_link_tag and javascript_include_tag in the common view.


JavaScript package manager (Gem's package manager in Rails is Bundler). It is responsible for managing front-end modules such as Webpack, Vue.js, and React.js supported by Rails from Rails.

Yarn is not included by default, so you have to install it yourself.

Webpacker: One of the Rails gems that makes it easy to manage your assets with Webpack. Webpacker cannot be used unless Yarn is installed.

Difference between 〇〇 and △△

__ * * __ render returns a view immediately after the action, while redirect_to causes the browser to re-request to another URL after the action. The view is displayed without describing render or redirect_to in the action because Rails will automatically return a view with the same name as the action name.

__ * <Difference between save and save!> * __ The save method returns false if there is a validation error, and the contents of that error can be viewed with the errors method. The save! method raises an exception instead of false if there is a validation error, so it should definitely be saved! It is appropriate to use it at that time. In other words, when using it as a branch process of an if statement, we want to return true or false instead of an error, so we do not add!

__ * * __ The find method raises the error ʻActiveRecord :: RecordNotFoundwhen there is no data. Thefind_by` method returns nil when there is no data.

Therefore, in the login process, we want to return nil instead of an error when we are not logged in, that is, when there is no session [: user_id], so we use the find_by method.

Other notes

About routing

Not only the role of connecting controller actions from the combination of URL and HTTP method, but also One route creates a helper method to easily create a URL using the URL pattern name described in the Prefix part that appears when you type rails routes. The second argument (URL pattern name) _path of the link_to method is the URL helper method generated by routing.

About migration

It is better to describe the migration file not only to raise the version but also to raise or lower it. In the change method, Rails will do the rollback process to lower the version without permission from the description of only the code to raise the version. The $ rails db: migrate: redo command will lower the version once and then return it, so you can check if you can roll back. It is easier to deal with troubles especially in team development if you have a habit of always checking this.

About the mechanism of cookies

First, in response to the browser's first request, the server returns a response including cookie information, and the browser stores the server's domain information and its cookie information. From the next time onward, the server will acquire the previous information from the cookie information included in the request from the browser and update it. The updated cookie information is passed to the browser and saved. By repeating this, the information is continuously updated on the browser side.

Overall impression after learning

Rails often does it for me! That was impressive. I felt once again that I should know the other side because it is convenient. Also, I was learning and it was more like studying development with Ruby on Rails than studying Ruby on Rails. It was a great learning experience because it was a practical development flow and the mechanism was described in detail. Recommended for basic learning!

Recommended Posts

Ruby on Rails 5 quick learning practice guide that can be used in the field Summary
Ruby on Rails5 Quick Learning Practice Guide 5.2 Compatible Chapter2
Ruby on Rails5 Quick Learning Practice Guide 5.2 Compatible Chapter3
Learning Ruby with AtCoder Beginners Selection [Some Sums] Increase the methods that can be used
Summary of ORM "uroboroSQL" that can be used in enterprise Java
Until ruby can be used on windows ...
[Rails] "pry-rails" that can be used when saving with the create method
Cloud IDE: Heroku couldn't be installed in the Ruby on Rails tutorial
Ruby array methods that can be used with Rails (other than each)
[Ruby On Rails] In the create action and destroy action, emergency measures when redirect_to action:: show cannot be (cannot be used)
[Ruby] Methods that can be used with strings
About the case that ("b" .. "aa") could not be used in Ruby Range
How to resolve errors that occur in the "Ruby on Rails" integration test
[Ruby on Rails Tutorial] Error in the test in Chapter 3
About the matter that hidden_field can be used insanely
Convenient shortcut keys that can be used in Eclipse
The story that the port can no longer be used in the Spring boot sample program
[Ruby on Rails] Only the user who posted can edit
Summary of css selectors that can be used with Nookogiri
Ruby on rails learning record -2020.10.03
Ruby on rails learning record -2020.10.04
Ruby on rails learning record -2020.10.05
Ruby on rails learning record -2020.10.09
The case that @Autowired could not be used in JUnit5
Firebase-Realtime Database on Android that can be used with copy
[Ruby on Rails] Quickly display the page title in the browser
Four-in-a-row with gravity that can be played on the console
Ruby on Rails basic learning ①
[Question] Can nullif be used in the count function in JPQL?
(Ruby on Rails6) Display of the database that got the id of the database
Ruby on rails learning record-2020.10.07 ②
Ruby on rails learning record-2020.10.07 ①
Ruby on rails learning record -2020.10.06
Ruby on Rails validation summary
Static analysis tool that can be used on GitHub [Java version]
[Ruby on Rails] Posting function that only logged-in users can post
SwiftUI View that can be used in combination with other frameworks
I summarized the flow until implementing simple_calendar in Ruby on Rails.
Things to remember and concepts in the Ruby on Rails tutorial
Ruby on Rails Overview (Beginner Summary)
Ruby on Rails variable, constant summary
Ruby on Rails Japanese-English support i18n
Ruby methods often used in Rails
I implemented the multiple image upload function in Rails so that multiple images can be slid for the post
[Spring Boot] List of validation rules that can be used in the property file for error messages
About the problem that the server can not be started with rails s
Library summary that seems to be often used in recent Android development (2019/11)
"" Application.js "is not present in the asset pipeline" error in Ruby on Rails
How to debug the processing in the Ruby on Rails model only on the console
Ruby on Rails6 Practical Guide cp13 ~ cp15 [Memo]
part of the syntax of ruby ​​on rails
Ruby on Rails6 Practical Guide cp7 ~ cp9 [Memo]
[ERROR message display] A simplified version that can be used at any time with the rails partial template.
Rails refactoring story learned in the field
Ruby on Rails in Visual Studio Codespaces
Ruby on Rails6 Practical Guide cp4 ~ cp6 [Memo]
Beginners create portfolio in Ruby on Rails
Ruby on Rails6 Practical Guide cp10 ~ cp12 [Memo]
Ruby on Rails6 Practical Guide cp16 ~ cp18 [Memo]
[Ruby on Rails] Solving the addiction when setting crontab using whenever in EC2
Technology excerpt that can be used for creating EC sites in Java training