Re: Hatred towards Nested Polymorphic Paths

Chris Cruft
2007-07-08T20:04:24Z

Josh Writes:

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

But isn''t that the rub?  Who says the ids must be unique?  True, Rails
support for composite keys makes it less-than-direct to convert the
REST resource with composite keys into an AR model with unique keys,
but from a UI point of view, some may just want to expose more
intuitive composite keys:

    /month/3/week/2/day/1
    /albums/6552/track/1
    /cuisines/46598/popular_restaurants/1

The path components really are part of the UI -and sometimes a very
visible part.  I want mine to be intuitive and that sometimes means
nested with non-unique IDs.

On Jul 7, 1:25 am, Josh Peek <joshp...@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.