title: Rails namespace root error
body: <p>I'm running into a couple of errors when i try to define a root to a namespace. To recreate this, I'll rebuild a project from scratch.</p>
  
  <pre><code>rails new rails_test
  cd rails_test
  rails generate controller admin
  rake db:migrate
  </code></pre>
  
  <p>Now I put some boilerplate in app/controllers/admin_controller.rb</p>
  
  <pre><code>class AdminController &lt; ApplicationController
      def index
  
      end
  end
  </code></pre>
  
  <p>in app/views/admin/index.html.erb</p>
  
  <pre><code>&lt;p&gt;Index&lt;/p&gt;
  </code></pre>
  
  <p>and finally in config/routes.rb</p>
  
  <pre><code>  root to: 'admin#index'
  </code></pre>
  
  <p>This all works perfectly, when i start the server and hit '/' (root) url (it goes to the admin index page), but it's not what I want.</p>
  
  <p>This is meant to be part of a bigger project and I want to hit the /admin url and get the admin index so (following from <a href="http://guides.rubyonrails.org/routing.html#using-root" rel="nofollow">http://guides.rubyonrails.org/routing.html#using-root</a>) I change routes.rb to:</p>
  
  <pre><code>  namespace :admin do
      root to: "admin#index"
    end
  </code></pre>
  
  <p>but I get a routing error:</p>
  
  <blockquote>
    <p>uninitialized constant Admin</p>
  </blockquote>
  
  <p>with a routes list containing 1 line:</p>
  
  <blockquote>
    <p>admin_root_path    GET     /admin(.:format)    admin/admin#index</p>
  </blockquote>
  
  <p>My thinking from reading the end of this last line is that I'm already in the admin namespace so maybe i don't need to specify the controller index is in so I try changing routes to:</p>
  
  <pre><code>  namespace :admin do
      root to: "index"
    end
  </code></pre>
  
  <p>But that gives me an ArgumentError saying "missing :action" on the 'root to: "index"' line.</p>
  
  <p>I can get around it by using scope, but it looks like using namespace is a bit cleaner and I want to understand whats going wrong here.</p>
  
  <p>Ruby/Rails versions</p>
  
  <pre><code>ruby -v -&gt; ruby 1.9.3p392 (2013-02-22) [i386-mingw32]
  rails -v -&gt; Rails 4.0.0
  </code></pre>
  
  <p>Any help is apprechiated</p>