title: Best way to organize Rails controller index
body: <p>Our app can track clients who walk in to our clinic without an appointment. We started with a simple WalkIn model and WalkInsController.</p>
  <p>Then we added another type of walk-in, then another ... so now our #index action has to filter between four different walk-in types and sometimes treat them differently.</p>
  <p>The other REST actions (besides #show) are mostly the same between types, but might have some minor differences. We also have a few non-REST methods that don't really fit anywhere else.</p>
  <p>So, at minimum, this #index action needs to be tamed.</p>
  <p>First thought: I'll namespace walk_ins just for #index:</p>
  <pre><code>namespace :walk_ins do
    get 'clinic'      =&gt; 'clinic_walk_ins#index',      :as =&gt; :clinic
    get 'group'       =&gt; 'group_walk_ins#index',       :as =&gt; :group
    get 'assessment'  =&gt; 'assessment_walk_ins#index',  :as =&gt; :assessment
    get 'initial'     =&gt; 'initial_walk_ins#index',     :as =&gt; :initial
  end
  
  resources :walk_ins, except: [ :index ] do
    member do
      get :eligible_initial_appointments
      patch :mark_follow_up_as_completed
    end
    collection do
      get :follow_up_due
    end
  end
  </code></pre>
  <p>So I'd create <code>WalkIns::InitialWalkInsController</code>, etc., for the #index action for initial walk-ins, and I'll leave top-level <code>WalkInsController</code> for the rest of the resources.</p>
  <p>But since the namespace is the same as the top-level controller -- <code>walk-ins</code> -- I can't do <code>walk_ins/initial</code>, because Rails will treat it as <code>walk_ins#show</code> and say it can't find a WalkIn with ID &quot;show&quot;.</p>
  <p>I could simply change the name of the namespace, but <code>walk_ins</code> really makes the most sense.</p>
  <p>Second pass -- embed all resource routes into the namespace:</p>
  <pre><code>namespace :walk_ins do
    get 'clinic'      =&gt; 'clinic_walk_ins#index',      :as =&gt; :clinic
    get 'group'       =&gt; 'group_walk_ins#index',       :as =&gt; :group
    get 'assessment'  =&gt; 'assessment_walk_ins#index',  :as =&gt; :assessment
    get 'initial'     =&gt; 'initial_walk_ins#index',     :as =&gt; :initial
  
    resources :walk_ins, except: [ :index ] do
      member do
        get :eligible_initial_appointments
        patch :mark_follow_up_as_completed
      end
      collection do
        get :follow_up_due
      end
    end
  end
  </code></pre>
  <p>This works, and it's great to have a discrete controller for each type of walk_in#index.</p>
  <p>But now every resource that isn't index has to be inside <code>walk_ins/walk_ins</code>.</p>
  <p>For example, to edit WalkIn 3, the URL is:</p>
  <p><code>/walk_ins/walk_ins/3/edit</code></p>
  <p>That seems like ... not what I want.</p>
  <p>What is the best way to organize this?</p>