Re: Hatred towards Nested Polymorphic Paths

Daniel N
2007-07-07T18:22:59Z

On 7/8/07, Josh Peek <joshpeek@gmail.com> wrote:
>
>
> On Jul 7, 1:40 am, "Daniel N" <has....@gmail.com> wrote:
> > 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.
>
> Whats the join model in this case? Can you pastie the example? (http://
> pastie.caboo.se/)
>
> Because each clip (and every other model you mentioned) has its own
> unique id, you can always use that to find it.



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.

In my case it''s a view setting.

As another example,

users have mailboxes, and each mailbox can have many postcards
Mailboxes -> Postcards

Postcards are shared between users and mailboxes.  One use likes to see a
particular postcards picture, whilst one likes to see it''s text.  The
only
place to put this view information that I can see is in the join table
between the postcard and mailbox.

With this situation you need both the mailbox and the clip id to determine
what view state the postcard should be in.  The nested routes fit this
perfectly.