But then I add a method in the accounts_controller
def logout
blah blah
end
I want to link to it so I do:
<%=link_to ‘Logout’ ,:controller=>‘accounts’, :action=>‘logout’%>
which creates: Logout
But it just calls the ‘show’ method of the accounts_controller and
trys to find an account with an id of ‘logout’
What am I missing here?
How can I call the logout method.
It doesn’t seem to be a problem if I dont specify a controller, but in
this case the link is in the layout and needs to specify the
controller.
I can do:
map.logout ‘logout’, :controller => ‘accounts’, :action => ‘logout’
Not very elegant though
But what is the point of having the default routes if you cant get to
them?
You can make named routes for everything using the technique Phillip
posted, you could rearrange your actions to be more restful (maybe a
sessions controller, and map login to sessions#create, or move your
default routes to a different position in the routes file (order is
important here).
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.