ruby on rails - Action Controller Exception: Using GET instead of DELETE -


i have following routes.rb file:

hchq::application.routes.draw   resources :users   resources :sessions, only: [:new, :create, :destroy]    match '/signup',  to: 'users#new'   match '/signin',  to: 'sessions#new'   match '/signout', to: 'sessions#destroy', via: :delete end 

when run rake routes get:

      users    /users(.:format)          users#index             post   /users(.:format)          users#create    new_user    /users/new(.:format)      users#new   edit_user    /users/:id/edit(.:format) users#edit        user    /users/:id(.:format)      users#show             put    /users/:id(.:format)      users#update             delete /users/:id(.:format)      users#destroy    sessions post   /sessions(.:format)       sessions#create new_session    /sessions/new(.:format)   sessions#new     session delete /sessions/:id(.:format)   sessions#destroy      signup        /signup(.:format)         users#new      signin        /signin(.:format)         sessions#new     signout delete /signout(.:format)        sessions#destroy 

and yet, when go http://localhost:3000/signout following:

routing error: action controller exception

in log get: actioncontroller::routingerror (no route matches [get] "/signout"):

which, shouldn't having [delete] instead of [get] on /signout route? if how change it?

by navigating straight browser address, you're performing request. browsers default submitting requests when user enters url , ask render page.

you should insert link in view using #link_to , passing delete method option, this:

link_to "signout", signout_path, :method => :delete 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -