Named Routes

41 views
Skip to first unread message

George Anderson

unread,
May 7, 2012, 2:44:29 PM5/7/12
to focused_controller
I'm having an issue with named routes not being recognized.


focused_controller_routes do
get '/login' => 'sessions#new', as: 'login'
get '/logout' => 'sessions#destroy', as: 'logout'

resources :sessions
end


`rake routes`:

login GET /
login(.:format) sessions#new
logout GET /
logout(.:format) sessions#destroy
sessions GET /sessions(.:format)
SessionsController::Index
POST /
sessions(.:format) SessionsController::Create
new_session GET /sessions/new(.:format)
SessionsController::New
edit_session GET /sessions/:id/edit(.:format)
SessionsController::Edit
session GET /sessions/:id(.:format)
SessionsController::Show
PUT /
sessions/:id(.:format) SessionsController::Update
DELETE /
sessions/:id(.:format) SessionsController::Destroy

Am I missing something to get named routes working?

If the `focused_controller` code needs some work to add support for
named routes I'm happy to give it a go if you could provide me some
direction.

Thanks,

/g

Jon Leighton

unread,
May 7, 2012, 2:51:00 PM5/7/12
to focused_c...@googlegroups.com
I think the documentation is wrong about this working. I don't think it
works at the moment (but it should).

For now you should do:

focused_controller_routes do
get '/login' => 'SessionsController::New', as: 'login'
get '/logout' => 'SessionsController::Destroy', as: 'logout'

resources :sessions
end

Please could you file an issue on Github? I'd also be happy to see a
patch to make it work.

Thanks
--
http://jonathanleighton.com/

George Anderson

unread,
May 7, 2012, 3:12:25 PM5/7/12
to focused_controller
Reply all
Reply to author
Forward
0 new messages