Double directories in url

I’m moved some controllers to
app/admin/

and add this to the routes

map.connect ‘admin/:controller/:action/:id’

The controllers have the admin prefix :

class Admin::DoSomethingController < ApplicationController

After the first time accessing the url the ‘admin’ dir is added again.
The
result url looks like this:

http://…/admin/admin/do_something/edit/1

How can this be fixed?? Ideas , anyone?

Rails 1.2.2
Gems 0.9.2


Best Regards,
-Larry
“Work, work, work…there is no satisfactory alternative.”
— E.Taft Benson

After the first time accessing the url the ‘admin’ dir is added again. The
result url looks like this:

http://…/admin/admin/do_something/edit/1

How can this be fixed?? Ideas , anyone?

Why not just remove that route? I do the same thing as you but don’t
have
that route… just a single route to map “/admin” to the default
controller in my admin area.

-philip

Philip H. wrote:

After the first time accessing the url the ‘admin’ dir is added again. The
result url looks like this:

http://…/admin/admin/do_something/edit/1

How can this be fixed?? Ideas , anyone?

Why not just remove that route? I do the same thing as you but don’t
have
that route… just a single route to map “/admin” to the default
controller in my admin area.

-philip

This is correct.

When you move controller into a subfolder like that, the new “url name”
of that controller is “admin/do_stuff”. With the route
“admin/:controller”, the url name of the controller “admin/do_stuff”
gets inserted into :controller, producing “admin/admin/do_stuff”.

So get rid of that admin route and lets ActionController do its thang.

Thanks,
-Larry

On 2/9/07, Alex W. [email protected] wrote:


Best Regards,
-Larry
“Work, work, work…there is no satisfactory alternative.”
— E.Taft Benson

one quick and dirty way to fix controller problems like these is to
include the “/” in the beginning of your RAILS methods.

IE:
normally you may have
link_to :controller => “admin/main”, :action => “do_something”, :id =>
object.id

This would be changed to
link_to :controller => “/admin/main”, :action => “do_something”, :id =>
object.id

and that forces the routing to start at the root.

hope that helps

–jake

Anton A. wrote:

Philip H. said the following on 02/09/2007 06:02 PM:


controller in my admin area.
I’m having a similar-but-different problem.

I’m working on a wiki with webs (books in i2 parlance), so the normal
url reads
http://sitename.com/Web/WikiWordTopic

(do I use “:requirements” to make sure?)

so the admin interface for doing things that the normal wiki user can’t
is

http://sitename.com/admin/web for the list
http://sitename.com/admin/web/Web for a specific web
http://sitename.com/admin/web/Web/WikiWordTopic for a specific topic

and drill down for its attributes.

Yes, I still have things to sort out like what the urls are for
the user to login and return to the access controlled topic (or is that
done
via cookies), edit a topic … and of course what all that looks like in
the
mappings…

  1. Philip could you post the line from your routes.rb, please, to
    clarify.

  2. If you move the controllers to app/controllers/admin do you have to
    add
    the
    Admin:: prefix?

Or, to ask it all another way, is there a different way to
compartmentalise
both the code and the URL?
(such as …/do_something/1?admin perhaps)


If the box says ``Windows 95 or better’’, it should run on Linux, right?
(Seen on Usenet)

Philip H. said the following on 02/09/2007 06:02 PM:


controller in my admin area.
I’m having a similar-but-different problem.

I’m working on a wiki with webs (books in i2 parlance), so the normal
url reads
http://sitename.com/Web/WikiWordTopic

(do I use “:requirements” to make sure?)

so the admin interface for doing things that the normal wiki user can’t
is

http://sitename.com/admin/web for the list
http://sitename.com/admin/web/Web for a specific web
http://sitename.com/admin/web/Web/WikiWordTopic for a specific topic

and drill down for its attributes.

Yes, I still have things to sort out like what the urls are for
the user to login and return to the access controlled topic (or is that
done
via cookies), edit a topic … and of course what all that looks like in
the
mappings…

  1. Philip could you post the line from your routes.rb, please, to
    clarify.

  2. If you move the controllers to app/controllers/admin do you have to
    add
    the
    Admin:: prefix?

Or, to ask it all another way, is there a different way to
compartmentalise
both the code and the URL?
(such as …/do_something/1?admin perhaps)


If the box says ``Windows 95 or better’’, it should run on Linux, right?
(Seen on Usenet)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs