Matching and Routes in Rails

前端 未结 3 1973
南笙
南笙 2021-02-07 18:08

I generated a controller and changed the routes but opening the links yields errors on my local server.

Generating controller and routes



        
3条回答
  •  甜味超标
    2021-02-07 18:27

    You can use match, you've gotta add a via: option:

    match '/about',    to: 'static_pages#about', via: :get
    match '/team',     to: 'static_pages#team', via: :get
    match '/contact',  to: 'static_pages#contact', via: :get
    

    You can also pass other HTTP verbs to via: if you need to, like via: [:get, :post]

    Source: Rails Routing Guide

提交回复
热议问题