title: Rails 3 routing question: sub-resources
body: <p>I have 2 models: User and Interest.</p>
  
  <p>To get a specific users interest, you can visit this URL:</p>
  
  <pre><code>/users/1/interests
  </code></pre>
  
  <p>Now to my problem. Each User can have several children, which is references to other users. Now I want to get a specific child, by doing this:</p>
  
  <pre><code>/users/1/children/1/interests
  </code></pre>
  
  <p>But I'm not sure how to set this up in the routes.rb. Both URL's should call the show action in the interests_controller, where I just want to check like this:</p>
  
  <pre><code>def show
    @user = User.find params[:id]
    if params[:child_id]
      @user = @user.children.find_by_id params[:child_id]
    end
    @interests = @user.interests
  end 
  </code></pre>
  
  <p>So I want to use the same interests_controller for both URL's, but I'm not sure how to write that in my routes.rb?</p>