title: Rails 3 has_one routing
body: <p>I have two classes:</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    :has_one :foo
  end
  
  class Foo &lt; ActiveRecord::Base
    :belongs_to :user 
  end
  </code></pre>
  
  <p>The Foo is optional.</p>
  
  <p>I created the following routing:</p>
  
  <pre><code>resources :users do
    resources :foo
  end
  </code></pre>
  
  <p>Which results in the following routes:</p>
  
  <pre><code>GET    /users/:user_id/foo(.:format)              {:controller=&gt;"foos", :action=&gt;"index"}
  user_foos POST   /users/:user_id/foo(.:format)              {:controller=&gt;"foos", :action=&gt;"create"}
  new_user_foo GET    /users/:user_id/foo/new(.:format)          {:controller=&gt;"foos", :action=&gt;"new"}
  GET    /users/:user_id/foo/:id(.:format)          {:controller=&gt;"foos", :action=&gt;"show"}
  PUT    /users/:user_id/foo/:id(.:format)          {:controller=&gt;"foos", :action=&gt;"update"}
  user_foo DELETE /users/:user_id/foo/:id(.:format)          {:controller=&gt;"foos", :action=&gt;"destroy"}
  edit_user_foo GET    /users/:user_id/foo/:id/edit(.:format)     {:controller=&gt;"foos", :action=&gt;"edit"}
  </code></pre>
  
  <p>Questions:</p>
  
  <ol>
  <li>It seems like the Index and Show actions are redundant.  Should one of them be removed?  If so, which one?</li>
  <li>The :id parameter in the Show action seems unnecessary, as user_id is a foreign key in the foos table and there is only one foo per user.  Am I mistaken?</li>
  <li>I would like to have a graceful way to route to the New action if there isn't a foo.  One option would be to test @user.foo.nil? in the FooController's Show or Index action, then redirect to the New action.  Is there a better way?</li>
  </ol>
  
  <p>Thanks for your time.</p>