Resourceful Routes in Ruby

From the Ruby on Rails cheat sheet · Routes · verified Jul 2026

Resourceful Routes

RESTful routes with resources

ruby
# Full CRUD routes
resources :posts

# Limit to specific actions
resources :posts, only: [:index, :show]
resources :posts, except: [:destroy]

# Nested resources
resources :users do
  resources :posts
end
✅ resources generates 7 RESTful routes automatically
💡 Use only/except to limit generated routes
🔍 Shallow nesting prevents deep URL structures
⚡ Check routes with rails routes command
routesrestresources

Continue with Ruby on Rails

Save the full cheat sheet or work through every related task.

More Ruby tasks

Back to the full Ruby on Rails cheat sheet