Problems with accessing controllers in sub tree directory

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?

Try putting a slash in front of the controller param:

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

Joe

What about

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

?

Vish

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

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

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

Probably. Why do you have nested controllers?

Try

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

Vish

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs