I'm linking to the destroy action for the Sessions controller like this:
<%= link_to "Sign out", session_path, method: :delete %>
Routes.rb:
resources :sessions, only: [:new, :create, :destroy]
Rails complains about the link above:
No route matches {:action=>"destroy", :controller=>"sessions"} missing required keys: [:id]
How do I link to the destroy action and keeping the REST/resource methodology in Rails when there's no object ID to provide for the link?
For sessions with adjacent nodes, direct session routing. For sessions that traverse one or more intermediate nodes, one of the following: Intermediate session routing (ISR), which provides a route that does not change during the course of the session.
The Session Smart Router integrates multiple middlebox capabilities (security, routing, firewall, VPN, and load balancer) into a single routing platform. This simplifies the overall network architecture and minimizes the costs and deployment time for new network functions.
IP Routing is an umbrella term for the set of protocols that determine the path that data follows in order to travel across multiple networks from its source to its destination. Data is routed from its source to its destination through a series of routers, and across multiple networks.
Dynamic routing is a mechanism through which routing information is exchanged between routers to determine the optimal path between network devices. A routing protocol is used to identify and announce network paths.
It is best to treat the routes to your sessions controller as a singular resource
routes.rb
resource :sessions
Doc: http://guides.rubyonrails.org/routing.html#singular-resources
This will give you a route that you can use without ID's
DELETE /sessions sessions#destroy
destroy
is a member route, you need to pass id
in the params to make it work, but you can do this to convert it to a collection route
resources :sessions, only: [:new, :create] do
delete :destroy, on: :collection
end
Hope that helps!
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