Forum: Ruby on Rails Routes working with subdirectories repeat subdirectory...

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Daniel W. (Guest)
on 2006-01-25 08:37
(Received via mailing list)
Hi all.

Views associated with admin controllers must always specify both
:controller
and :action when using link_to.

Example:

<%= link_to 'Edit', { :controller => '/raid_manager', :action =>
'edit_raid_template', :id => raid_template.id } %>

The above is being called from within the Admin::RaidManagerController.
The
controller was generated by using the Rails generate script, with a
filename
argument of "admin/RaidManager". Whenever I use that format, it prepends
Admin:: to my class name - why? I know :: is the scope resolution
operator,
but there's scarce documentation about, even in the pick axe book.
(That's
more of an aside question.)

If I use link_to without specifying the controller, the link itself
works,
but then I get something like:

xyz.com/admin/admin/raid_manager/edit_raid_template

It repeats the admin part. I also get the same effect even if I DO
include
the controller without the preceeeding /.

The routes that handle the admin area looks like:

map.connect '/admin/', :controller => 'admin/news_manager'
map.connect '/admin/:controller/:action/:id'

I don't like having to continually reference the controller, and I feel
like
I shouldn't have to. Also, I've found I'm unable to break out of the
admin/... URL once I'm in it.So like if I were to log out, and redirect
someone to :controller => 'pages', it would still look like admin/pages.
ARGH!

- Rabbit
Daniel W. (Guest)
on 2006-01-25 09:04
(Received via mailing list)
That's interesting. If I get rid of the routing rule, standard link_to's
work fine. I know this will come back to haunt me though. =/

- Rabbit

---
This topic is locked and can not be replied to.