Re: polymorphic_url and namespaces

Michael Koziarski
Sat, 10 May 2008 03:01:25 -0000

>  From my perspective it would make a lot of sense to have
> polymorphic_url to
>
> - delegate to article_path when we''re outside of the namespace but
> - delegate to admin_article_path when we''re inside of the
namespace
>
> It has been argued in [1] that polymorphic_url just does its "best
> guess" and thus the current behaviour was correct at that time.

It definitely does it''s ''best guess'',  but
that''s not to say it''s best
is good enough.  The all blacks did their best in the recent rugby
world cup, the french still kicked their ass :).

> Now, there currently doesn''t seem to be way to determine the
current
> namespace in a controller (and thus in polymorphic_url). From looking
> at routes building/recognition etc. it might not be too hard to pass
> the :namespace option from the route definition to the route (while
> building it) and then to the controller instance (after recognition).
>
> Am I missing something obvious?

We could pass the namespace option in the routes, however what about
just regular controllers in modules.  Are they in a namespace?  Also,
things like render :partial and friends need to be aware of these
namespaces.

Definitely sounds like something that''d be good to clean up and if
you''re interested in hacking on it, let us know. Hopefully
we''ll have
a 2.1 branch out of the way soon and can get to work on the backlog.

--
Cheers

Koz