Thursday, May 12, 2016

An in-Depth Look at Basic Rails Routing

The purpose of tutorial is to explain, in a beginner tone, how URL mapping happens in a Rails application. I will not be able to cover all the information about Rails Routing, but I'll do my best to talk about the basic aspects. This part of the tutorial will focus on Simple Routes, the next part we will talk on Resourceful Routes.

The Ruby on Rails routing system handles requests in a unique way. It examines the URL of incoming requests and determines the controller action responsible for handling each request. It makes use of the special syntax specified in the routes file, config/routes.rb, in doing this mapping. This routes file controls every URL aspect of your web application, thus it is important we look into it.

Rails Routes File

The generated file contains instructions on how it can be used. Let's leave that and go dig into creation of routes.

Creating a Regular Route

The basic means of creating a route involves mapping a URL to a controller and an action. When the Rails router sees a request it dispatches it to a controller's action matching the URL.

Continue reading %An in-Depth Look at Basic Rails Routing%


by Kingsley Silas via SitePoint

No comments:

Post a Comment