Re: Hatred towards Nested Polymorphic Paths

Daniel N
2007-07-07T06:40:39Z

On 7/7/07, Evan Weaver <eweaver@gmail.com> wrote:
>
>
> I tend to agree with this. I don''t really understand the need to
> "canonically" identify a resource based on its context.
>
> Other thoughts?
>
> Evan
>
>
> > On 7/7/07, Josh Peek <joshpeek@gmail.com> wrote:
> > >
> > > I have a real grudge against the new nested polymorphic path
magic
> > > stuff. I feel it encourages and gives people an excuse to write
overly
> > > compelled routes. Resources should NOT be nested more than one
level
> > > deep.
> > >
> > > "/companies/1/people/1" == BAD
> > > "/people/1" == GOOD
> > >
> > > I have no problem with nested collections.
> > >
> > > "/companies/1/people"
> > >
> > > You shouldn''t need to be scoping person #1 if its the
unique id.
> > >
> > > I''ve seen alot of defect and enhancement tickets going
by Trac showing
> > > its immaturity and lack of real need. None of this stuff has been
> > > merge with the stable, so its not to late to change things. It
should
> > > really be pulled from Edge and into a plugin,
> > > "nested_polymorphic_paths".
> > >
> > > Its not in the spirit of Rails to be providing tools to help you
> > > practice bad habits.
> > >
> > >
> > > > >
> > >
> >
> >
> > --
> > Evan Weaver
> > Cloudburst, LLC
> >



I wondered about the usefulness of this one too when it came out.  But I in
fact have a situation where I feel it is warranted to have the nested routes
like this.

Each user has a collection of books.
Each book has a collection of clips.

Clips can be shared between books.
A Clip has a default view depending on which book your in when your looking
at it.  ( Data kept in the join model of the :through association )

This makes it important to have both pieces of information.  This is I
believe the same for any has_many :through association where you have
additional information in the join model.  Without both pieces of
information you can''t identify the correct join model to use and
therefore
the extra piece of information you need.

Please let me know if there is another way to do what I''m suggesting.

Cheers
Daniel