[Rails] Routes working with subdirectories repeat subdirectory...

Rabbit
Wed, 25 Jan 2006 06:36:54 -0000

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
-------------- next part --------------
An HTML attachment was scrubbed...