I am struggling with the route setup for a Rails application. I have installed restful_authentication and mostly followed the instructions. I have set up the routes this way:
map.login '/login', :controller => 'sessions', :action => 'new' map.logout '/logout', :controller => 'sessions', :action => 'destroy' map.resource :session
If you’re not logged in, you’re redirected to http://localhost:3000/session/new. It makes some kind of sense, as the code in lib/authenticated_system.rb says redirect_to new_session_path.
But I thought the routes mapping was supposed to work both ways (code to URL and URL to code). Can someone explain? Thanks
map.resource :sessioncreates a few named resources for you includingnew_session_path(see ActionController::Resources).map.loginandmap.logoutare just helper routes to make your code easier to understand.map.login(which generateslogin_path) points to the same controller/action combo asnew_session_pathdoes, it’s just easier to remember at a glance what it does.