Re: polymorphic_url and namespaces

Sven Fuchs
Sat, 10 May 2008 09:43:22 -0000

On 10.05.2008, at 05:01, Michael Koziarski wrote:
> It definitely does it''s ''best guess'',  but
that''s not to say it''s best
> is good enough.

Sure! I hope my phrasing didn''t sound harsh.

> The all blacks did their best in the recent rugby
> world cup, the french still kicked their ass :).

Hehe. I have no idea what you are talking about ;D

> We could pass the namespace option in the routes, however what about
> just regular controllers in modules.  Are they in a namespace?

When we pass the namespace option to the route we can also pass it
back from #recognize and set it to the current controller instance
(like params). So the controller would always know if it has been
instantiated for a request through a "namespaced" route or not.

Thus the user would have full control: if he maps a route to a
controller inside of a module but doesn''t use the namespace option in
the route definition the controller would end up with no namespace set
for that request. If the same controller is also mapped with a
namespaced route and that route recognizes a request path the
controller would have a namespace set.

When the controller can access the current namespace it can use it in
#polymorphic_url to do a "better guess".

> Also,
> things like render :partial and friends need to be aware of these
> namespaces.

By that you mean calls to polymorphic_url from within partials?
Definitely. I believe that should work the same way as above.

> 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.

Ok, fine. I''ll have a stab at that.

I guess it makes more sense to discus implementation specific
questions on #rails-contrib.