Re: polymorphic_url and namespaces

Mislav Marohnić
Sat, 10 May 2008 13:29:06 -0000

Sven,

+1 for namespace awareness. I've been making my own helpers to wrap route
calls and inject the current namespace and I can tell it's a pain (it's
certainly bug-prone). If the framework handled this, it would be much
better.


On Sat, May 10, 2008 at 11:43 AM, Sven Fuchs <svenfuchs@artweb-design.de>
wrote:

>
> 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.
>
>
> --
> sven fuchs                      svenfuchs@artweb-design.de
> artweb design           http://www.artweb-design.de
> grünberger 65           + 49 (0) 30 - 47 98 69 96 (phone)
> d-10245 berlin          + 49 (0) 171 - 35 20 38 4 (mobile)
>
>
>
>
> >