Routing:
When you go out to a restaurant you place an order with your waiter, your waiter then puts that order in, and the kitchen prepares your order. Once the kitchen is done preparing your order, the waiter brings your order to you. This concept applies similarly when a client utilizes the internet. A client makes a request to the server(backend) and the server returns data back to the client(frontend).
Routing with Rails:
Ruby on rails allows programmers to use the 7 different routes to execute the different action methods mapped to the object within the app>controllers.rb. Custom routing are created in config>routes.rb where resources also are used.
Custom Routing:
When a client puts a request into the application for '/lawyers/:id', the request fetches the custom method of lawyer in the app>controller>users_controller.rb.
Here, user is set to a variable and active record rescue_from is used as our error handling when .find is used. To check if the routing was successfully created use Postman to test route:
Custom Route Works!!!
Top comments (0)