Route namespace and link_to.

5 views
Skip to first unread message

ruben....@gmail.com

unread,
Apr 13, 2008, 9:56:35 AM4/13/08
to Ruby on Rails: Talk
Hello,

In my routes.rb file I have a namespace declared:

map.namespace(:admin) do |admin|
admin.resources :pictures
admin.resources :admins
end

then in my erb template for the admin/admins controller I have a
link_to tag as follows:

<%= link_to "Login", :controller => "login", :action => "login" %>

Unfortunately this is giving me the path /admin/login/login instead of
the correct /login/login is there anyway to stop that admin namespace
from being inserted into the path?

Thanks,
Ruben

Tom D.

unread,
Jan 17, 2011, 9:54:27 AM1/17/11
to rubyonra...@googlegroups.com
the simplest way would be:

<%= link_to "Login", :controller => "/login", :action => "login" %>
# "/login" rather than just "login"

however if you're using one of the many authentication plugins out
there, you're more likely to want to add these to your routes:

map.logout '/logout', :controller => 'sessions', :action =>
'destroy'
map.login '/login', :controller => 'sessions', :action =>
'new'

--
Posted via http://www.ruby-forum.com/.

Reply all
Reply to author
Forward
0 new messages