title: Redirect/call method from another controller in a different namespace in Rails
body: <p>I have a pretty typical situation where I have a <code>'/dashboard'</code> which should render a different view for different user roles (i.e. client, admin, etc.).</p>
  
  <p>I am open to more elegant suggestions but my thought was to have one route definition for dashboard like so:</p>
  
  <p><strong>routes.rb</strong></p>
  
  <pre><code>resource :dashboard
  </code></pre>
  
  <p>and to have a <strong>dashboards_controller.rb</strong> like so:</p>
  
  <pre><code>class DashboardsController &lt; ApplicationController
    def show
      if current_user.has_role?('sysadmin')
        // show system admin dashboard
      elsif
        // show a different dashboard
  
      // etc
      end
    end
  end
  </code></pre>
  
  <p>Now I would like that each dashboard gets built in its role specific namespaced dashboard_controller, ex: <code>controllers/admin/dashboard_controller.rb</code>. This way, each dashboard can be appropriately built up in the right place.</p>
  
  <p>The way I am trying to do this is to redirect from my main <code>dashboards_controller</code> to the <code>admin/dashboard_controller</code> like so:</p>
  
  <pre><code>redirect_to :controller =&gt; 'admin/dashboard_controller', :action =&gt; 'index'
  </code></pre>
  
  <p>But it is not working, presumably because I am not sure how to reference a namespaced controller from here.</p>
  
  <p>How can I achieve this?</p>
  
  <p>(If there is a more elegant solution I am open but I thought this was pretty good).</p>
  
  <p>I am using devise and cancancan.</p>