The request is sent to the route mapping, which parses the URL, analyzes the configuration of /routes.rb and, if the URL matches the route, it looks for the controller file whose name matches the controller part of the URL (for example, http: // localhost / categories will look for DomainController)
Then one of two things happens:
- If you use the Rails secure route, the route marker uses heuristics to determine which of the 7 actions to call: GET on the last multiple part maps to the index; GET is mapped to the identification part after the plural is displayed for display (for example, category / 1 or category / something or category / 1-something); The POST for the last multiple part is displayed for creation; PUT for the identification part after the plural is displayed for updating; DELETE to the same URL is displayed for destruction; new and edit are displayed in GET for categories / new and categories / edit.
- If you have a custom action, you must have a method in the controller object with the same name.
The selected action is executed, and then Rails either displays the template / file / action specified in the render call in the action, or searches for a file with the same name as the action, and ends with .html.erb (by default) in the app / views directory /.
Simple
source share