I'm trying to run 'rails console' and I keep getting the following error message:
in normalize_conditions!': You should not use thematchmethod in your router without specifying an HTTP method. (RuntimeError)
If you want to expose your action to both GET and POST, addvia: [:get, :post]option.
If you want to expose your action to GET, useget` in the router:
Instead of: match "controller#action"
Do: get "controller#action"
I can't find the solution on Stack Overflow, what should I do?
My routes.rb file is:
Myapp::Application.routes.draw do
resources :users do
member do
get :following, :followers
end
end
resources :sessions, only: [:new, :create, :destroy]
resources :microposts, only: [:create, :destroy]
resources :relationships, only: [:create, :destroy]
root to: 'static_pages#home'
# Named routes:
match '/signup', to: 'users#new'
match '/signin', to: 'sessions#new'
match '/signout', to: 'sessions#destroy', via: :delete
match '/help', to: 'static_pages#help'
match '/about', to: 'static_pages#about'
match '/contact', to: 'static_pages#contact'
end
sounds like you have an issue in your routes.rb file. Probably the first thing to do is comment any line that you're using a match route in; or, as the error message suggests, add via: [:get, :post] to its options.
Such as:
match 'path', :to => 'controller#action', :via => [:get, :post]
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