# Problems with accessing controllers in sub tree directory

**URL:** <https://www.ruby-forum.com/t/problems-with-accessing-controllers-in-sub-tree-directory/70151>\
**Category:** Rails\
**Created:** [September 27, 2006, 4:05am UTC](https://www.ruby-forum.com/t/problems-with-accessing-controllers-in-sub-tree-directory/70151 "2006-09-27T04:05:10Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [September 27, 2006, 4:05am UTC](https://www.ruby-forum.com/t/problems-with-accessing-controllers-in-sub-tree-directory/70151/1 "2006-09-27T04:05:10Z")

</div>

Hey guys,

I used “script/generate controller admin/event”

How do I link to the views and the controller when it’s inside a  
directory.

I tried

\<%= link\_to “some link”, :controller=\>“event”,:action=\>“index” %\>

\<%= link\_to “some link”, :controller=\>“admin/event”,:action=\>“index” %\>

\<%= link\_to “some link”, :controller=\>“admin”,:action=\>“index” %\>

\<%= link\_to “some link”, :controller=\>“event”,:action=\>“event/index” %\>

NOTHING seems to work.

Any ideas?

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [September 27, 2006, 4:38am UTC](https://www.ruby-forum.com/t/problems-with-accessing-controllers-in-sub-tree-directory/70151/2 "2006-09-27T04:38:21Z")

</div>

Try putting a slash in front of the controller param:

\<%= link\_to “some link”, :controller=\>"/admin/event",:action=\>“index” %\>

Joe

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [September 27, 2006, 8:30am UTC](https://www.ruby-forum.com/t/problems-with-accessing-controllers-in-sub-tree-directory/70151/3 "2006-09-27T08:30:15Z")

</div>

What about

\<%= link\_to “some link”, :controller=\>"/admin/event", :action=\>“index”  
%\>

?

Vish

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [September 27, 2006, 12:51pm UTC](https://www.ruby-forum.com/t/problems-with-accessing-controllers-in-sub-tree-directory/70151/4 "2006-09-27T12:51:25Z")

</div>

Hey guys, I tried this as well. No luck either. Its weird because when I  
put that in, the URL is [www.mydomain.com/admin/event](http://www.mydomain.com/admin/event) and the page is  
blank, even though there is content in the index.rhtml file.

Does this work for you guys?

Vishnu G. wrote:

> What about
> 
> \<%= link\_to “some link”, :controller=\>“/admin/event”, :action=\>“index”  
> %\>
> 
> ?
> 
> Vish

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [September 27, 2006, 5:44pm UTC](https://www.ruby-forum.com/t/problems-with-accessing-controllers-in-sub-tree-directory/70151/5 "2006-09-27T17:44:31Z")

</div>

Do I have to change something in my routing file to handle these nested  
controllers?

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [September 28, 2006, 3:29pm UTC](https://www.ruby-forum.com/t/problems-with-accessing-controllers-in-sub-tree-directory/70151/6 "2006-09-28T15:29:29Z")

</div>

Eric G. wrote:

> Hey guys, I tried this as well. No luck either. Its weird because when I  
> put that in, the URL is [www.mydomain.com/admin/event](http://www.mydomain.com/admin/event) and the page is  
> blank, even though there is content in the index.rhtml file.

It works for me. If the URL is orrect and the page is blank, not an  
error, then it’s not a routing problem. Make sure your index.rhtml is in  
views/admin/event/.

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [September 27, 2006, 7:43pm UTC](https://www.ruby-forum.com/t/problems-with-accessing-controllers-in-sub-tree-directory/70151/7 "2006-09-27T19:43:38Z")

</div>

Probably. Why do you have nested controllers?

Try

map.connect ‘admin/event/:action’, :controller =\> ‘event’

Vish

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [September 28, 2006, 6:32pm UTC](https://www.ruby-forum.com/t/problems-with-accessing-controllers-in-sub-tree-directory/70151/8 "2006-09-28T18:32:14Z")

</div>

Hmm, well, the thing is, I did have an index.rhtml file and even if I  
didn’t, I should have gotten and error, or my layout should have  
rendered.

How are you writing out your routing, is it [www.mysite.com/admin/event/](http://www.mysite.com/admin/event/)  
and that would render the index.rhtml file in the views/admin/event  
directory?

Ashley T. wrote:

> Eric G. wrote:
> 
> > Hey guys, I tried this as well. No luck either. Its weird because when I  
> > put that in, the URL is [www.mydomain.com/admin/event](http://www.mydomain.com/admin/event) and the page is  
> > blank, even though there is content in the index.rhtml file.
> 
> It works for me. If the URL is orrect and the page is blank, not an  
> error, then it’s not a routing problem. Make sure your index.rhtml is in  
> views/admin/event/.
