Knowledge required to display tweets

Hi, this is Nim.

Today, I learned the knowledge necessary for .

Data will be handled when displaying tweets. The basic processing of handling is collectively called CRUD. Rails divides CRUD into 7 actions to realize the process.

■ What is CRUD? ~ This is an acronym for basic processing regarding the handling of application data. The function of the application is implemented by combining these four processes. C: Create R: Read (read) U: Update D: Delete

■ What are the seven actions? ~ In order to realize CRUD, it is necessary to describe each process. Rails has customary settings for those actions, There are various actions. index: List display show: Detailed display new: Generate create: save edit: edit update: update destroy: delete

The routing of these seven actions can be done by using the resources method. It is possible to set all at once.

■ resources method ~ A method that automatically produces routes to 7 actions. If you specify the symbol: tweets in the argument of resources, it will be in the path of / tweets. The corresponding routing is generated. You have set the routing for all seven actions.

■ only option If only is added as an option to ~ resources, only the specified action Automatically produce routing.

Now let's talk about . If you want to display similar headers and footers on multiple pages It is very inefficient because you have to write the same description in each template file. Therefore, let's put together the common parts of the page.

■ Layout template ~ This is a collection of common parts of the application view file. In all views of head information, headers, footers, etc. in layout templates By describing the common parts, each template file will have a separate appearance. All you have to do is write it. For Rails, the file application.html.erb is the layout template.

■ application.html.erb file ~ This file corresponds to the Rails template. Also called a layout file. application.html.erb is located in the app / vies / layouts directory. In application.html.erb, head element and body element are described from the beginning.

■ yield method ~ It is a method to expand each template file to the layout template. By describing yield, in the case of index action, in the template file If the content of index.html.erb is a new action, new.html.erb is It will be expanded to the yield description part.

Therefore, it is not necessary to write the information of the head element on each page. With the same idea, headers and footers to be displayed on all screens are also included in this layout template. If you describe it, it will be reflected on each page.

Next, it is the knowledge necessary to adjust the appearance part.

■ stylesheet_link_tag method ~ A helper method that allows you to specify the CSS file to read. The CSS file to read is Place it in a directory called app / assets / stylesheets /. In the argument of stylesheet_link_tag of application.html.erb, Because it says'application', it's in the app / assets / stylesheets / directory Indicates to load a CSS file called application.css.

■ application.css file ~ It is a file for collecting CSS files that is prepared from the beginning in Rails. Also known as a manifest file.

In application.css, you can specify CSS that applies to the entire application. If you specify a special notation such as * = followed by another CSS file, etc. It is possible to read multiple CSS files at once.

■ require_tree ~ CSS files under the directory given as an argument in alphabetical order It has a function to read all. In application.css, there is a description of require_tree. From the beginning. The. (Dot) given in the argument represents the current directory.

Understanding these roles will help you view your tweets. We will continue to output.

Thank you for reading to the end.

Nim

Recommended Posts

Knowledge required to display tweets
Summary of knowledge required to pass Java SE8 Silver
Knowledge required for object-oriented refactoring
[Java] How to display Wingdings
[rails] How to display db information
Android Development-Try to display a dialog-
To display multiple lines with UILabel