Matching and Routes in Rails

前端 未结 3 1047
执笔经年
执笔经年 2021-02-07 18:16

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:19

    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

提交回复
热议问题