If you are new to ruby then you must have wondered about what is routes in ruby, so today I will discuss everything about routes in detail. Rail routes are used to dispatch URl to the controllers action. it is used to generate path for particular action in the ruby. method to assign routes
get 'users/13'
this route will be used to get the information of id 13 of user in show action inside the controller. If you will type rake routes in console you will see the below text
get '/users/:id', to: 'users#show', as: 'user'
It will hit the show method in your specific controller Resources routing in rails, resource routing is used to generate all the routes necessary for particular controller it generates all the method such as GET, POST, PATCH, PUT and DELETE. each method is used to perform specific action on the resource.
How we define resource in config/routes.rb file
resources :users
0 Comment(s)