How to: redirect_to through a folder hierarchy (upwards)

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

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

Anyone…?

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!

Tom,

You should be able to do like this.

redirect_to :controller => “/members”, :action => ‘show’

Thanks,
Kilari.
http://kilari.co.in

Thanks, Kilari - that was it !