[RUBY] Rails tutorial (6th edition) Background operation of profile editing

table of contents

  1. Create new account
  2. Login (including Friendly Forwarding and persistent login) (https://qiita.com/akarin0519/items/f241b9699e156741a8d1)
  3. ** Edit profile **
  4. Reset Password (https://qiita.com/akarin0519/items/ea873bb165ed4099a40e)
  5. Post Micropost
  6. Follow and unfollow (https://qiita.com/akarin0519/items/f1b90b18577650a40ea9)

3. Edit profile

Operation screen

User operations for profile editing with the app proceed in the following two steps.

  1. Click the edit link while logged in to open the profile edit screen.
  2. Modify the edit items and click the submit button to return to the user's home screen.

Background operation

The background operation executed in each of the above steps is as follows.

  1. If you click the edit profile link while logged in, a GET request will be sent to/users /: id/edit and the edit action of the Users controller will be executed. In this edit action, the user corresponding to params [: id] is searched from the DB and stored in the instance variable @ user. Then, the view (users/edit.html.erb) corresponding to the edit action is displayed, and @ user is passed here. In addition, edit.html.erb is a profile edit screen.
  2. Since the contents of @ user passed to the form_with function in edit.html.erb exist, Rails automatically determines that the user information has been updated. Therefore, when the submit button of the edit form is clicked, a PATCH request is sent to the/users/edit path and the update action of the Users controller is executed. In this update action, it tries to update only the value of the key that can be accessed by the parameter received from the input form, and if the update is successful, redirects to the user's home screen (root_url).

Recommended Posts

Rails tutorial (6th edition) Background operation of profile editing
Rails tutorial (6th edition) Background operation of login function
Rails tutorial (6th edition) Follow/unfollow background operation
Rails tutorial (6th edition) Background operation of password reset function
Rails Tutorial (6th Edition) -Explanation of background operation for each function-
Rails tutorial (6th edition) Background operation of the posting function of the micro post
Rails Tutorial (4th Edition) Summary
Rails Tutorial (4th Edition) Memo Chapter 6
Rails Tutorial 6th Edition Learning Summary Chapter 10
Rails Tutorial 6th Edition Learning Summary Chapter 7
Rails Tutorial 6th Edition Learning Summary Chapter 4
Rails Tutorial 6th Edition Learning Summary Chapter 9
Rails Tutorial 6th Edition Learning Summary Chapter 6
Rails Tutorial 6th Edition Learning Summary Chapter 5
Rails Tutorial 6th Edition Learning Summary Chapter 2
Rails Tutorial 6th Edition Learning Summary Chapter 3
Rails Tutorial 6th Edition Learning Summary Chapter 8
Rails Tutorial 4th Edition: Chapter 1 From Zero to Deployment
[Rails] Implementation of tutorial function
[Rails Struggle/Rails Tutorial] Summary of Rails Tutorial Chapter 2
[Rails Struggle/Rails Tutorial] Summary of Heroku commands
rails tutorial
rails tutorial
rails tutorial
rails tutorial
rails tutorial
rails tutorial
rails tutorial
I got an "ActionView :: Template :: Error: Permission denied" error in the test of 3.3.1 of Rails tutorial 6th edition, so I solved it.
A summary of only Rails tutorial setup related
Cloud9 is out of memory: Rails tutorial memorandum
[Rails tutorial] A memorandum of "Chapter 11 Account Activation"