A common category of web applications built with RoR are form-based apps, which give users a form for submitting data, which stores that data in a database and lets users view or modify those entries.
Displaying the form to the user
- A user enters a URL path on their browser and executes.
- When the URL path is executed, the browser sends a GET request for that URL.
- The GET request hits the rails router (config/routes.rb). The router maps the URL to a controller action to handle the request.
- The controller action receives the GET request and passes it on to the view.
- The view renders the page as HTML.
- The controller sends the HTML back to the browser. The page loads and the user sees the page with the form.
Submitting the form
- The user fills and submits the form.
- When the form is submitted, the browser sends a POST request to the Rails app.
- The POST request hits the rails router(config/routes.rb). The router maps the POST request to the correct controller action.
- The controller action receives the POST request. The controller action retrieves the submitted data from the form and uses the model to store the data into the database.
- The model completes its task.
- The controller action passes the request on to the view.
- The view renders the page as HTML.
- The controller sends the HTML back to the browser. The page loads and the user sees it.
Top comments (0)