Reputation: 151
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?
Upvotes: 1
Views: 32
Reputation: 691
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
Upvotes: 2