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.
rbenv:
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.
RDB:
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.
ruby:app/views/layouts/application.html.slim
= 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.
Yarn:
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.
__ * 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!
__ * find
method raises the error ʻActiveRecord :: RecordNotFoundwhen there is no data. The
find_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.
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.
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.
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.
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