I generated a controller and changed the routes but opening the links yields errors on my local server.
Generating controller and routes
rails generate controller StaticPages home about team contact
Change routes.rb
MyApp::Application.routes.draw do
root to: 'static_pages#home'
match '/about', to: 'static_pages#about'
match '/team', to: 'static_pages#team'
match '/contact', to: 'static_pages#contact'
end
The root path work but none of the 'about, 'team', or 'contact' links work. This is the error I get:
"You should not use the match
method in your router without specifying an HTTP method. 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""
Why can't I use 'match'?
match
method has been deprecated.
Use get
for GET and post
for POST.
get '/about', to: 'static_pages#about'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With