# Linking to subdirectories in controller

**URL:** <https://www.ruby-forum.com/t/linking-to-subdirectories-in-controller/76866>\
**Category:** Rails\
**Created:** [November 21, 2006, 8:07pm UTC](https://www.ruby-forum.com/t/linking-to-subdirectories-in-controller/76866 "2006-11-21T20:07:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [November 21, 2006, 8:07pm UTC](https://www.ruby-forum.com/t/linking-to-subdirectories-in-controller/76866/1 "2006-11-21T20:07:26Z")

</div>

How do I link (with link\_to) to a controller and action inside a  
subdirectory in controllers? I get an error saying “Unknown action. No  
action responded …”.

And do I understand it correctly that I need to have a similar  
subdirectory in views as well?

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [November 21, 2006, 8:23pm UTC](https://www.ruby-forum.com/t/linking-to-subdirectories-in-controller/76866/2 "2006-11-21T20:23:24Z")

</div>

PÃ¥l BergstrÃ¶m wrote:

> How do I link (with link\_to) to a controller and action inside a  
> subdirectory in controllers? I get an error saying “Unknown action. No  
> action responded …”.

link\_to :controller =\> ‘/admin/products’, :action =\> ‘list’

> And do I understand it correctly that I need to have a similar  
> subdirectory in views as well?

That is correct.

Note that the behavior seems to be generally discouraged as it has led  
to unpredictable behavior before. (Search the archives for relevant  
discussions.)

- Roderick

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [November 21, 2006, 8:27pm UTC](https://www.ruby-forum.com/t/linking-to-subdirectories-in-controller/76866/3 "2006-11-21T20:27:51Z")

</div>

Roderick van Domburg wrote:

> PÃ¥l BergstrÃ¶m wrote:
> 
> > How do I link (with link\_to) to a controller and action inside a  
> > subdirectory in controllers? I get an error saying “Unknown action. No  
> > action responded …”.
> 
> link\_to :controller =\> ‘/admin/products’, :action =\> ‘list’
> 
> > And do I understand it correctly that I need to have a similar  
> > subdirectory in views as well?
> 
> That is correct.
> 
> Note that the behavior seems to be generally discouraged as it has led  
> to unpredictable behavior before. (Search the archives for relevant  
> discussions.)
> 
> - Roderick

Thanks. Yes I’ve seen that after reading here. I think I’ll leave it as  
I had it with one level.

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [November 21, 2006, 9:45pm UTC](https://www.ruby-forum.com/t/linking-to-subdirectories-in-controller/76866/4 "2006-11-21T21:45:11Z")

</div>

Roderick van Domburg wrote:

> Note that the behavior seems to be generally discouraged as it has led  
> to unpredictable behavior before. (Search the archives for relevant  
> discussions.)

What I don’t understand is how to deal with the public view and the  
admin part. Let’s say I have a users table. To that I have a user model.  
But what if I want to keep the user controller just for admin and  
another controller for login. Can I create what ever controllers I want  
but tell it to use a certain model? Or does it always have to have a  
correlation, name-wise?

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [November 21, 2006, 9:59pm UTC](https://www.ruby-forum.com/t/linking-to-subdirectories-in-controller/76866/5 "2006-11-21T21:59:56Z")

</div>

PÃ¥l BergstrÃ¶m wrote:

> What I don’t understand is how to deal with the public view and the  
> admin part. Let’s say I have a users table. To that I have a user model.  
> But what if I want to keep the user controller just for admin and  
> another controller for login. Can I create what ever controllers I want  
> but tell it to use a certain model? Or does it always have to have a  
> correlation, name-wise?

Every model is available in every controller. They’re not linked  
namewise.

- Roderick
