title: Angular JS ngResource with nested resources
body: <p>I'm trying out angular JS and I want to get data from a nested resource defined in my rails application.  </p>
  
  <p>I wrote the following lines:</p>
  
  <pre><code>UserMission = $resource("/users/:user_id/user_missions/:id", {user_id: "@user_id", id: "@id"}, {update: {method: "PUT"}})
  $scope.user_missions = UserMission.query()
  </code></pre>
  
  <p>and I get the following error:</p>
  
  <pre><code>  Processing by UsersController#show as JSON
    Parameters: {"id"=&gt;"user_missions"}
    User Load (0.6ms)  SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1  [["id", 1]]
    User Load (0.5ms)  SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1  [["id", "user_missions"]]
  Completed 404 Not Found in 10ms
  
  ActiveRecord::RecordNotFound (Couldn't find User with id=user_missions):
    app/controllers/users_controller.rb:100:in `current_resource'
    app/controllers/application_controller.rb:34:in `authorize'
  </code></pre>
  
  <p>My rails routes are organized like so:</p>
  
  <pre><code>resources :users do
    resources :user_missions
  end
  </code></pre>
  
  <p>I think it comes down to me not understanding "@id".  It says it comes off of the "data object" from the <a href="http://docs.angularjs.org/api/ngResource.%24resource">angularjs site</a> and I am not exactly sure what that means.</p>
  
  <p>Any help would be appreciated thanks.</p>
  
  <p><strong>Update</strong></p>
  
  <p>Another question.  I have not found any examples of rails with angularjs using nested resources (an example User <code>has_many :missions, through: :user_missions</code> ) with <code>$resource</code>.  Is there a good example of angularjs manipulating nested resources (with <code>$resource</code>) with ajax?</p>