What do you have in the routes file?
Try to put
map.log_out 'logout', :controller => 'sessions', :action => 'destroy'
in your routes.
Then just
<%= link_to "Sign out", log_out_url %>
for the dropdown link.
EDIT
It all depends on how you specify routing.
Since you had map.log_out in routing, then the URL http: // localhost: 3000 / logout is picked up by this and headed for the correct action.
If you have:
<%= link_to "logout", :controller=> "sessions", :action=> "destroy" %>
This will create a link for http: // localhost: 3000 / session . But he does nothing for routing. You still need to specify the correct routes.
Note that Rails does not add the destroy action to the URL. (It will not create http: // localhost: 3000 / session / destroy .) It is assumed that if you have an destroy action, you will send it using DELETE http verb, for some reason it is not completely perfect, and on in fact, it does not by default send the verb DELETE.
You can make it do this:
<%= link_to "logout", {:controller=> "user_sessions", :action=> "destroy"}, :method => :delete%>
It still wonβt work unless you type it correctly. If you put the following in routes:
map.resource :session
Then the rails will generate routing for all verbs and indicate default actions for them, including DELETE. More information can be found here: Rails Routing from Outside In .
This whole page is worth reading over and over until you understand it. Routing is the key to understanding Rails!
For a simple controller such as sessions, itβs easier to just specify the log_out route and then a link to log_out_url ..
(Hope that makes sense, sleep deprivation is creeping!)