在路线上遇到错误[红宝石]

问题描述 投票:0回答:1

我正在阅读Michael的Hartl Ruby on Rails教程,并且在route.rb中遇到错误。

这是我在routes.rb中的代码

  Rails.application.routes.draw do
  get 'users/new'
  match '/signup', :to => 'users#new'
  match '/contact', :to => 'pages#contact'
  match '/about', :to => 'pages#about'
  match '/help', :to => 'pages#help'
  root :to => 'pages#home'
end

这是我得到的错误:

 You should not use the `match` method in your router without specifying an HTTP method. (ArgumentError)
If you want to expose your action to both GET and POST, add `via: [:get, :post]` option.
If you want to expose your action to GET, use `get` in the router:
  Instead of: match "controller#action"
  Do: get "controller#action"

我很困惑。我应该使用get“ controller#action”还是匹配?使用匹配时正确的代码是什么?

ruby-on-rails ruby get routes match
1个回答
0
投票

是,您应该使用get或指定match '/signup', :to => 'users#new', via: :get。基本上这就是错误的意思。

您可以检查文档:Rails Routing from the Outside In

© www.soinside.com 2019 - 2024. All rights reserved.