# STI, Namespaces, REST and link\_to

**URL:** <https://www.ruby-forum.com/t/sti-namespaces-rest-and-link-to/178643>\
**Category:** Rails\
**Created:** [November 8, 2009, 9:25pm UTC](https://www.ruby-forum.com/t/sti-namespaces-rest-and-link-to/178643 "2009-11-08T21:25:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bluething](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c4cdca/32.png) [@bluething](https://www.ruby-forum.com/u/bluething)\
**Post date:** [November 8, 2009, 9:25pm UTC](https://www.ruby-forum.com/t/sti-namespaces-rest-and-link-to/178643/1 "2009-11-08T21:25:05Z")

</div>

hello,

i’ve got the STI-hierarchy Dictionary, InternalDictionary \< Dictionary  
and OnlineDictionary \< Dictionary.  
Every submodel has its own controller. E.g. InternalDictionary is  
handled by  
Voc::InternalDictionaryController. As you see everything works inside  
the namespace Voc (except the models).

In an index.html.erb of a controller i walk through all types of  
dictionaries:

\<% for dictionary in @dictionaries %\>

 \<%= link\_to 'Edit', [:voc,dictionary], :method =\> :get %\> \<% end %\>

This leads to the path “voc\_internal\_dictionary” for objecs of type  
InternalDictionary and to “voc\_online\_dictionary” for objects of type  
OnlineDictionary. So far so good.

But I want to call the method “edit” or a methodname completely  
different from the CRUD-names.I’d need something like

\<%= link\_to 'Edit', [:voc,dictionary], :action =\> "edit" %\>

I tried:

\<%= link\_to 'Edit',edit\_voc\_dictionary\_path %\> but that doens't behave polymorphic and calls the edit method of the dictionary-controller directly.

Any ideas?

Thanks a lot  
Lutz

---

<div class="post-metadata">

**Author:** ![bluething](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c4cdca/32.png) [@bluething](https://www.ruby-forum.com/u/bluething)\
**Post date:** [November 8, 2009, 9:38pm UTC](https://www.ruby-forum.com/t/sti-namespaces-rest-and-link-to/178643/2 "2009-11-08T21:38:05Z")

</div>

back again, I have found an answer meanwhile:

link\_to ‘Edit’, polymorphic\_url([:voc,dictionary],:action =\> :edit)

does exactly what I need.
