Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What is the principle of gem?

Shulou Source: shulou.com Published: 2022-06-01 03:12:00 09月30日 Update

Most people do not understand the knowledge points of this article "what is the principle of gem", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "what is the principle of gem" article.

This gem is used to implement a tree structure, such as a category, and there are subcategories below, so you can use it at this time, and you can also use it when you reply to a post and others will reply to you. There is a submenu under a menu, and there can be a submenu under the submenu, and there are menu items under the submenu, which can realize a kind of tree structure menu. Its principle is also very simple, in the model is to achieve a self-association, if in a comment (comment) model, define a children (child), and then define a parent (parent),: class_name is' Comment'. So how do they achieve the connection, that is to say, the child needs to know who the father is, and the father needs to know what children it has. It is related through a field in the data store. In this gem, this field is called parent_id. If we create a root, root = Comment.create, at this time, the parent_id of root* is null, it is a root, children = root.children.create, and this children is a child of root. So children's parent_id is root's id.

The above is the content of this article on "what is the principle of gem". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to the industry information channel.

Tags: Menu content principle child time association field that is article father knowledge article structure classification under that is value most of the data. Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Tech Info NVidia Xiaomi macOS