简体   繁体   中英

Getting an error with routes [ruby on rails]

I am going through Michael's Hartl Ruby on Rails tutorial and I am getting an error in the routes.rb.

This is my code in 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

And this is the error I get:

 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"

I am confused. Should I use get "controller#action" or match? And what is the proper code when using match?

Yes, you should use get or specify match '/signup', :to => 'users#new', via: :get . Basically that's what error says.

You can check the docs: Rails Routing from the Outside In

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM