** Day 16 of Calendar Planning 2020 ** It's been about 3 months since I started studying programming, so I will leave a note of what I learned in the article as an output. I would be happy if I could help anyone entering the world of programming. Please let me know if there are any words that are wrong, wrong, or misunderstood ^^ I'm sorry if it's hard to read the words for a long time. I will do my best to get used to it little by little.
There are seven basic actions used in rails Controller. (As an exception, you may make your own name.) In principle, the names to be given when you want to play the seven roles introduced below are defined. Please list!
Action name | role |
---|---|
new | Create new data |
create | Add data |
index | Display a list of data |
show | Display the contents of the data |
edit | Edit the data |
update | Update data |
destroy | Delete data |
I think there are many ways to express words, so please make it easy for you to understand! (To the extent that the meaning does not change ...)
new
It has the role of ** creating a new **.
For example A place to write letters or upload photos to post something on SNS Where to write articles on a blog That is the new action!
create
It has the role of ** adding and registering data **.
For example Created with new action (continuation of the above example) There is a button like "Post", right? That is the create action!
It is not displayed anywhere just by writing. No one can see it. It's in a state where it doesn't remain! Only after creating it will it remain as data.
index
It has the role of ** list display **.
For example Many people's posts are lined up on SNS, right? That is the index action.
show
It has the role of ** displaying contents and details **.
For example If you click and tap what is displayed in the index, you can see all the contents, or the screen will be only that post, right? It's a show action.
edit
** Edit ** Has a role.
For example I made a mistake in what I posted! The information has been updated, so I want to change the posted content! You edit at that time, right?
The place to edit is the edit action.
With an action that is newly created where it is not new edit is an action to recreate something. (Similar to new.)
update
** Update ** has a role.
This is an image to save the edited contents. Use the create action to save the new. Use the update action to save the edit.
It may be easy to remember as a set.
update not only saves edit, but also updates other changes. Don't think of it as a set only with edit. (I wrote it, but ...)
It is an overwritten image! (I!!)
destroy
The role of ** delete **.
For example This is the action taken when deleting a post or deleting an account. Erase data from the database! (It seems to be a physical deletion.)
This is a digression There is also a logical deletion, and although it disappears on the screen, the data remains.
For example As an operation, I want to keep the history of ordering in the past. But the user wants to unsubscribe. It is used at such times. You can also process that data remains on the administrator's screen when you cannot log in from the user side (withdrawal). The action used at this time is update, not destroy! There seems to be a way to use update like this!
I've summarized it briefly, but it's just a basic action. In some cases, the index is displayed on the show screen. The above content is not absolute, but basically I will use it! It may be good to remember it with a feeling!
Recommended Posts