# Polymorphic\_url for index

**URL:** <https://www.ruby-forum.com/t/polymorphic-url-for-index/153304>\
**Category:** Rails\
**Created:** [November 14, 2008, 5:05pm UTC](https://www.ruby-forum.com/t/polymorphic-url-for-index/153304 "2008-11-14T17:05:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f07891/32.png) [@gabi](https://www.ruby-forum.com/u/gabi)\
**Post date:** [November 14, 2008, 5:05pm UTC](https://www.ruby-forum.com/t/polymorphic-url-for-index/153304/1 "2008-11-14T17:05:26Z")

</div>

Hello,

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

Thanks!

---

<div class="post-metadata">

**Author:** ![gabi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f07891/32.png) [@gabi](https://www.ruby-forum.com/u/gabi)\
**Post date:** [November 14, 2008, 5:36pm UTC](https://www.ruby-forum.com/t/polymorphic-url-for-index/153304/2 "2008-11-14T17:36:46Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![gabi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f07891/32.png) [@gabi](https://www.ruby-forum.com/u/gabi)\
**Post date:** [December 3, 2008, 6:31pm UTC](https://www.ruby-forum.com/t/polymorphic-url-for-index/153304/3 "2008-12-03T18:31:58Z")

</div>

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).
