Forum: Ruby on Rails polymorphic_url for index

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
38643ec0dd1506548e9f9fc7b4dcc22f?d=identicon&s=25 Gabi Ge (gabi)
on 2008-11-14 17:05
Hello,

How can I use polymorphic_url to generate the index action? It works
fine with the create action so far.

Thanks!
38643ec0dd1506548e9f9fc7b4dcc22f?d=identicon&s=25 Gabi Ge (gabi)
on 2008-11-14 17:36
Perhaps I should be more specific:

I'm using STI (single table inheritance) and I'm displaying the objects
using the same view. I need to put a link to the index. polymorphic_url
helped me so far, because it generates the new, create, update and edit
URLs  depending on the object type, but there seems to be no easy way to
generate the index URL.

Gabi Ge wrote:
> Hello,
>
> How can I use polymorphic_url to generate the index action? It works
> fine with the create action so far.
>
> Thanks!
Ef8ef6c9c8d2c6448d4260e34303a050?d=identicon&s=25 glennpow (Guest)
on 2008-12-03 18:31
(Received via mailing list)
Try:

polymorphic_url([@parent, ChildClass.new])

If the array contains an item which is new (not saved), then it uses
the plural form of path (index).
This topic is locked and can not be replied to.