Re: Hatred towards Nested Polymorphic Paths

Chris Cruft
2007-07-08T20:28:10Z

Josh,
I grok what Daniel is trying to say, but I can''t tell if you do or
not.  Perhaps this will help.

/mother/273753/child/234
/father/342986/child/234
/child/234

In all of those URLs it is very clear which single resource we are
referencing: Child 234.  But the URLs give very different context
information.  For the first URL, I want to show a pink background, in
the second I want to show a blue background and in the last one, I
want to show a white background, to give a simple example.

Context counts.

Now if we could only get Rails to help us identify that context more
accurately, I''d be happy [warning -going slightly off topic...].

Are these two URLs presenting the same context?

/users/17/groups/2/tags
/groups/2/users/17/tags

Short of routing these URLs to different (otherwise identical)
controllers or manually inspecting the URI, does anybody know how to
differentiate them?

Sure would be nice if Rails exposed the matched route to the
controller!   Perhaps an RO attribute of
ActionController::AbstractRequest set in
ActionController::Routing::RouteSet.recognize?



On Jul 7, 2:37 pm, Josh Peek <joshp...@gmail.com>
wrote:
> On Jul 7, 1:22 pm, "Daniel N" <has....@gmail.com> wrote:
>
> > I can''t pastie it unfortunately but it.  But I believe it
goes for any time
> > you use a has_many :through relationship with additional data in the
join
> > table.  Without both sides of the join, you can''t identify
join, and
> > therefore don''t have access to the extra data.
>
> You identify the join with the id of the join model. Thats the purpose
> of using has many though, exposing an actual model. If you could
> pastie on example, I could show you how to model it better.