Complete the code to add a constraint that only allows numeric IDs in the route.
get '/products/:id', to: 'products#show', constraints: { id: /[1]/ }
The regex \d+ matches one or more digits, ensuring the :id parameter is numeric.
Complete the code to restrict the route to only accept HTTP GET requests.
match '/search', to: 'search#index', via: :[1]
The via: :get option restricts the route to only respond to GET requests.
Fix the error in the route constraint to only allow lowercase letters for the username parameter.
get '/users/:username', to: 'users#show', constraints: { username: /[1]/ }
The regex [a-z]+ matches one or more lowercase letters, restricting the username accordingly.
Fill both blanks to create a route that only matches subdomains 'admin' or 'api'.
constraints subdomain: /[1]|[2]/ do get '/dashboard', to: 'dashboard#index' end
The regex admin|api matches either 'admin' or 'api' subdomains for the route.
Fill all three blanks to define a route with constraints on HTTP method, subdomain, and numeric ID.
constraints subdomain: /[1]/ do match '/items/:id', to: 'items#show', via: :[2], constraints: { id: /[3]/ } end
The route matches requests on the 'admin' subdomain, only GET method, and numeric IDs using \d+.