DEV Community

hmza
hmza

Posted on

πŸ›£οΈ Part 6 β€” Routing in Rails: Connect URLs to Actions

πŸ›£οΈ Part 6 β€” Routing in Rails: Connect URLs to Actions

Define routes in config/routes.rb:

 resources :posts 
Enter fullscreen mode Exit fullscreen mode

This creates CRUD routes:

  • GET /posts β†’ index
  • GET /posts/:id β†’ show
  • POST /posts β†’ create
  • PATCH /posts/:id β†’ update
  • DELETE /posts/:id β†’ destroy

Custom routes:

 get '/about', to: 'pages#about' 
Enter fullscreen mode Exit fullscreen mode

Top comments (0)