# How to: redirect\_to through a folder hierarchy (upwards)

**URL:** <https://www.ruby-forum.com/t/how-to-redirect-to-through-a-folder-hierarchy-upwards/175786>\
**Category:** Rails\
**Created:** [September 19, 2009, 5:20pm UTC](https://www.ruby-forum.com/t/how-to-redirect-to-through-a-folder-hierarchy-upwards/175786 "2009-09-19T17:20:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [September 19, 2009, 5:20pm UTC](https://www.ruby-forum.com/t/how-to-redirect-to-through-a-folder-hierarchy-upwards/175786/1 "2009-09-19T17:20:45Z")

</div>

Hi there,

how do I tell the current controller correctly to redirect\_to an action  
of another controller that is 1 level higher in the folder hierarchy  
than the current controller?

How I have tried: Within the current controller (called ‘incidents’), I  
have put:

redirect\_to :controller =\> ‘members’, :action =\> ‘show’, :id =\>  
@user.id

(Where ‘members’ is 1 level higher. And this doesn’t work.)

Thank you for any help with this!  
Tom

---

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [September 19, 2009, 7:33pm UTC](https://www.ruby-forum.com/t/how-to-redirect-to-through-a-folder-hierarchy-upwards/175786/2 "2009-09-19T19:33:45Z")

</div>

Are you creating subdirectories by hand and putting controllers in  
them like normal, or are you properly namespacing them? e.g.:

admin/incidents\_controller.rb:  
IncidentsController \< ApplicationController

-or-

admin/incidents\_controller.rb:  
Admin::IncidentsController \< ApplicationController

-eric

---

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [September 20, 2009, 11:02pm UTC](https://www.ruby-forum.com/t/how-to-redirect-to-through-a-folder-hierarchy-upwards/175786/3 "2009-09-20T23:02:12Z")

</div>

Anyone…?

---

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [September 19, 2009, 7:44pm UTC](https://www.ruby-forum.com/t/how-to-redirect-to-through-a-folder-hierarchy-upwards/175786/4 "2009-09-19T19:44:12Z")

</div>

Hi Eric,

My controller files contain:

controllers/admin/incidents\_controller.rb:  
class Admin::IncidentsController \< ApplicationController  
…  
end

controllers/members\_controller.rb:  
class MembersController \< ApplicationController  
…  
end

- I am in the ‘Admin::IncidentsController \< ApplicationController’, and  
need to
- redirect\_to the ‘show’ action in the ‘MembersController \<  
ApplicationController’

I also tried something this:  
redirect\_to :controller =\> ‘…/members’, :action =\> ‘show’

Thanks for helping!

---

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [September 21, 2009, 1:00am UTC](https://www.ruby-forum.com/t/how-to-redirect-to-through-a-folder-hierarchy-upwards/175786/5 "2009-09-21T01:00:31Z")

</div>

Tom,

You should be able to do like this.

redirect\_to :controller =\> “/members”, :action =\> ‘show’

Thanks,  
Kilari.  
[http://kilari.co.in](http://kilari.co.in)

---

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [September 21, 2009, 10:37am UTC](https://www.ruby-forum.com/t/how-to-redirect-to-through-a-folder-hierarchy-upwards/175786/6 "2009-09-21T10:37:00Z")

</div>

Thanks, Kilari - that was it !
