我正在阅读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”还是匹配?使用匹配时正确的代码是什么?
是,您应该使用get
或指定match '/signup', :to => 'users#new', via: :get
。基本上这就是错误的意思。