{"action":"created","comment":{"url":"https://api.github.com/repos/HippoTeam/hippo/pulls/comments/32479061","id":32479061,"diff_hunk":"@@ -1,49 +1,43 @@\n 'use strict';\n \n module.exports = function(app) {\n-  app.controller('cardsController', ['$scope', '$http', function($scope, $http) {\n+  app.controller('cardsController', ['$scope', 'RESTResource', function($scope, resource) {\n+    var Card = resource('cards');\n+\n     $scope.errors = [];\n     $scope.cards = [];\n \n     $scope.getAll = function() {\n-      $http.get('/api/cards')\n-        .success(function(data) {\n-          $scope.cards = data;\n-        })\n-        .error(function(data) {\n-          console.log(data);\n-          $scope.errors.push({msg: 'error retrieving cards'});\n-        });\n+      Card.getAll(function(err, data) {\n+        if(err) return $scope.errors.push({msg: 'error retrieving cards'});\n+        $scope.cards = data;\n+      });\n     };\n \n     $scope.createNewCard = function() {\n-      $http.post('/api/cards', $scope.newCard)\n-        .success(function(data) {\n-          $scope.cards.push(data);\n-          $scope.newCard = null;\n-        })\n-        .error(function(data) {\n-          console.log(data);\n-          $scope.errors.push({msg: 'could not create new card'});\n-        })\n+      var newCard = $scope.newCard;\n+      $scope.newCard = null;\n+      $scope.cards.push(newCard);\n+      Card.create(newCard, function(err, data) {\n+        if(err) return $scope.errors.push({msg: 'could not save new card' + newCard.personName});","path":"app/js/cards/controllers/cards_controller.js","position":40,"original_position":40,"commit_id":"4de02cabcc98a96a133827497dc22c763c19dd30","original_commit_id":"4de02cabcc98a96a133827497dc22c763c19dd30","user":{"login":"EeshanKumar","id":2320605,"avatar_url":"https://avatars.githubusercontent.com/u/2320605?v=3","gravatar_id":"","url":"https://api.github.com/users/EeshanKumar","html_url":"https://github.com/EeshanKumar","followers_url":"https://api.github.com/users/EeshanKumar/followers","following_url":"https://api.github.com/users/EeshanKumar/following{/other_user}","gists_url":"https://api.github.com/users/EeshanKumar/gists{/gist_id}","starred_url":"https://api.github.com/users/EeshanKumar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EeshanKumar/subscriptions","organizations_url":"https://api.github.com/users/EeshanKumar/orgs","repos_url":"https://api.github.com/users/EeshanKumar/repos","events_url":"https://api.github.com/users/EeshanKumar/events{/privacy}","received_events_url":"https://api.github.com/users/EeshanKumar/received_events","type":"User","site_admin":false},"body":"We should splice out newCard from $scope.cards on err. ","created_at":"2015-06-15T23:40:31Z","updated_at":"2015-06-15T23:40:31Z","html_url":"https://github.com/HippoTeam/hippo/pull/24#discussion_r32479061","pull_request_url":"https://api.github.com/repos/HippoTeam/hippo/pulls/24","_links":{"self":{"href":"https://api.github.com/repos/HippoTeam/hippo/pulls/comments/32479061"},"html":{"href":"https://github.com/HippoTeam/hippo/pull/24#discussion_r32479061"},"pull_request":{"href":"https://api.github.com/repos/HippoTeam/hippo/pulls/24"}}},"pull_request":{"url":"https://api.github.com/repos/HippoTeam/hippo/pulls/24","id":37735808,"html_url":"https://github.com/HippoTeam/hippo/pull/24","diff_url":"https://github.com/HippoTeam/hippo/pull/24.diff","patch_url":"https://github.com/HippoTeam/hippo/pull/24.patch","issue_url":"https://api.github.com/repos/HippoTeam/hippo/issues/24","number":24,"state":"open","locked":false,"title":"add REST resource - closes #23","user":{"login":"jowellv","id":7776969,"avatar_url":"https://avatars.githubusercontent.com/u/7776969?v=3","gravatar_id":"","url":"https://api.github.com/users/jowellv","html_url":"https://github.com/jowellv","followers_url":"https://api.github.com/users/jowellv/followers","following_url":"https://api.github.com/users/jowellv/following{/other_user}","gists_url":"https://api.github.com/users/jowellv/gists{/gist_id}","starred_url":"https://api.github.com/users/jowellv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jowellv/subscriptions","organizations_url":"https://api.github.com/users/jowellv/orgs","repos_url":"https://api.github.com/users/jowellv/repos","events_url":"https://api.github.com/users/jowellv/events{/privacy}","received_events_url":"https://api.github.com/users/jowellv/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-06-15T21:09:46Z","updated_at":"2015-06-15T23:40:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"15b34b9cdfd123765fcb7cb97bb9fbdb4ae49ad9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/HippoTeam/hippo/pulls/24/commits","review_comments_url":"https://api.github.com/repos/HippoTeam/hippo/pulls/24/comments","review_comment_url":"https://api.github.com/repos/HippoTeam/hippo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/HippoTeam/hippo/issues/24/comments","statuses_url":"https://api.github.com/repos/HippoTeam/hippo/statuses/4de02cabcc98a96a133827497dc22c763c19dd30","head":{"label":"HippoTeam:rest-resource","ref":"rest-resource","sha":"4de02cabcc98a96a133827497dc22c763c19dd30","user":{"login":"HippoTeam","id":12866671,"avatar_url":"https://avatars.githubusercontent.com/u/12866671?v=3","gravatar_id":"","url":"https://api.github.com/users/HippoTeam","html_url":"https://github.com/HippoTeam","followers_url":"https://api.github.com/users/HippoTeam/followers","following_url":"https://api.github.com/users/HippoTeam/following{/other_user}","gists_url":"https://api.github.com/users/HippoTeam/gists{/gist_id}","starred_url":"https://api.github.com/users/HippoTeam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HippoTeam/subscriptions","organizations_url":"https://api.github.com/users/HippoTeam/orgs","repos_url":"https://api.github.com/users/HippoTeam/repos","events_url":"https://api.github.com/users/HippoTeam/events{/privacy}","received_events_url":"https://api.github.com/users/HippoTeam/received_events","type":"Organization","site_admin":false},"repo":{"id":37347605,"name":"hippo","full_name":"HippoTeam/hippo","owner":{"login":"HippoTeam","id":12866671,"avatar_url":"https://avatars.githubusercontent.com/u/12866671?v=3","gravatar_id":"","url":"https://api.github.com/users/HippoTeam","html_url":"https://github.com/HippoTeam","followers_url":"https://api.github.com/users/HippoTeam/followers","following_url":"https://api.github.com/users/HippoTeam/following{/other_user}","gists_url":"https://api.github.com/users/HippoTeam/gists{/gist_id}","starred_url":"https://api.github.com/users/HippoTeam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HippoTeam/subscriptions","organizations_url":"https://api.github.com/users/HippoTeam/orgs","repos_url":"https://api.github.com/users/HippoTeam/repos","events_url":"https://api.github.com/users/HippoTeam/events{/privacy}","received_events_url":"https://api.github.com/users/HippoTeam/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/HippoTeam/hippo","description":"","fork":false,"url":"https://api.github.com/repos/HippoTeam/hippo","forks_url":"https://api.github.com/repos/HippoTeam/hippo/forks","keys_url":"https://api.github.com/repos/HippoTeam/hippo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/HippoTeam/hippo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/HippoTeam/hippo/teams","hooks_url":"https://api.github.com/repos/HippoTeam/hippo/hooks","issue_events_url":"https://api.github.com/repos/HippoTeam/hippo/issues/events{/number}","events_url":"https://api.github.com/repos/HippoTeam/hippo/events","assignees_url":"https://api.github.com/repos/HippoTeam/hippo/assignees{/user}","branches_url":"https://api.github.com/repos/HippoTeam/hippo/branches{/branch}","tags_url":"https://api.github.com/repos/HippoTeam/hippo/tags","blobs_url":"https://api.github.com/repos/HippoTeam/hippo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/HippoTeam/hippo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/HippoTeam/hippo/git/refs{/sha}","trees_url":"https://api.github.com/repos/HippoTeam/hippo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/HippoTeam/hippo/statuses/{sha}","languages_url":"https://api.github.com/repos/HippoTeam/hippo/languages","stargazers_url":"https://api.github.com/repos/HippoTeam/hippo/stargazers","contributors_url":"https://api.github.com/repos/HippoTeam/hippo/contributors","subscribers_url":"https://api.github.com/repos/HippoTeam/hippo/subscribers","subscription_url":"https://api.github.com/repos/HippoTeam/hippo/subscription","commits_url":"https://api.github.com/repos/HippoTeam/hippo/commits{/sha}","git_commits_url":"https://api.github.com/repos/HippoTeam/hippo/git/commits{/sha}","comments_url":"https://api.github.com/repos/HippoTeam/hippo/comments{/number}","issue_comment_url":"https://api.github.com/repos/HippoTeam/hippo/issues/comments{/number}","contents_url":"https://api.github.com/repos/HippoTeam/hippo/contents/{+path}","compare_url":"https://api.github.com/repos/HippoTeam/hippo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/HippoTeam/hippo/merges","archive_url":"https://api.github.com/repos/HippoTeam/hippo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/HippoTeam/hippo/downloads","issues_url":"https://api.github.com/repos/HippoTeam/hippo/issues{/number}","pulls_url":"https://api.github.com/repos/HippoTeam/hippo/pulls{/number}","milestones_url":"https://api.github.com/repos/HippoTeam/hippo/milestones{/number}","notifications_url":"https://api.github.com/repos/HippoTeam/hippo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/HippoTeam/hippo/labels{/name}","releases_url":"https://api.github.com/repos/HippoTeam/hippo/releases{/id}","created_at":"2015-06-12T22:29:06Z","updated_at":"2015-06-15T21:59:00Z","pushed_at":"2015-06-15T23:34:10Z","git_url":"git://github.com/HippoTeam/hippo.git","ssh_url":"git@github.com:HippoTeam/hippo.git","clone_url":"https://github.com/HippoTeam/hippo.git","svn_url":"https://github.com/HippoTeam/hippo","homepage":null,"size":0,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":10,"forks":0,"open_issues":10,"watchers":2,"default_branch":"master"}},"base":{"label":"HippoTeam:master","ref":"master","sha":"dee640bb35cf649f3333c46ae8845b2311497bdd","user":{"login":"HippoTeam","id":12866671,"avatar_url":"https://avatars.githubusercontent.com/u/12866671?v=3","gravatar_id":"","url":"https://api.github.com/users/HippoTeam","html_url":"https://github.com/HippoTeam","followers_url":"https://api.github.com/users/HippoTeam/followers","following_url":"https://api.github.com/users/HippoTeam/following{/other_user}","gists_url":"https://api.github.com/users/HippoTeam/gists{/gist_id}","starred_url":"https://api.github.com/users/HippoTeam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HippoTeam/subscriptions","organizations_url":"https://api.github.com/users/HippoTeam/orgs","repos_url":"https://api.github.com/users/HippoTeam/repos","events_url":"https://api.github.com/users/HippoTeam/events{/privacy}","received_events_url":"https://api.github.com/users/HippoTeam/received_events","type":"Organization","site_admin":false},"repo":{"id":37347605,"name":"hippo","full_name":"HippoTeam/hippo","owner":{"login":"HippoTeam","id":12866671,"avatar_url":"https://avatars.githubusercontent.com/u/12866671?v=3","gravatar_id":"","url":"https://api.github.com/users/HippoTeam","html_url":"https://github.com/HippoTeam","followers_url":"https://api.github.com/users/HippoTeam/followers","following_url":"https://api.github.com/users/HippoTeam/following{/other_user}","gists_url":"https://api.github.com/users/HippoTeam/gists{/gist_id}","starred_url":"https://api.github.com/users/HippoTeam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HippoTeam/subscriptions","organizations_url":"https://api.github.com/users/HippoTeam/orgs","repos_url":"https://api.github.com/users/HippoTeam/repos","events_url":"https://api.github.com/users/HippoTeam/events{/privacy}","received_events_url":"https://api.github.com/users/HippoTeam/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/HippoTeam/hippo","description":"","fork":false,"url":"https://api.github.com/repos/HippoTeam/hippo","forks_url":"https://api.github.com/repos/HippoTeam/hippo/forks","keys_url":"https://api.github.com/repos/HippoTeam/hippo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/HippoTeam/hippo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/HippoTeam/hippo/teams","hooks_url":"https://api.github.com/repos/HippoTeam/hippo/hooks","issue_events_url":"https://api.github.com/repos/HippoTeam/hippo/issues/events{/number}","events_url":"https://api.github.com/repos/HippoTeam/hippo/events","assignees_url":"https://api.github.com/repos/HippoTeam/hippo/assignees{/user}","branches_url":"https://api.github.com/repos/HippoTeam/hippo/branches{/branch}","tags_url":"https://api.github.com/repos/HippoTeam/hippo/tags","blobs_url":"https://api.github.com/repos/HippoTeam/hippo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/HippoTeam/hippo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/HippoTeam/hippo/git/refs{/sha}","trees_url":"https://api.github.com/repos/HippoTeam/hippo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/HippoTeam/hippo/statuses/{sha}","languages_url":"https://api.github.com/repos/HippoTeam/hippo/languages","stargazers_url":"https://api.github.com/repos/HippoTeam/hippo/stargazers","contributors_url":"https://api.github.com/repos/HippoTeam/hippo/contributors","subscribers_url":"https://api.github.com/repos/HippoTeam/hippo/subscribers","subscription_url":"https://api.github.com/repos/HippoTeam/hippo/subscription","commits_url":"https://api.github.com/repos/HippoTeam/hippo/commits{/sha}","git_commits_url":"https://api.github.com/repos/HippoTeam/hippo/git/commits{/sha}","comments_url":"https://api.github.com/repos/HippoTeam/hippo/comments{/number}","issue_comment_url":"https://api.github.com/repos/HippoTeam/hippo/issues/comments{/number}","contents_url":"https://api.github.com/repos/HippoTeam/hippo/contents/{+path}","compare_url":"https://api.github.com/repos/HippoTeam/hippo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/HippoTeam/hippo/merges","archive_url":"https://api.github.com/repos/HippoTeam/hippo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/HippoTeam/hippo/downloads","issues_url":"https://api.github.com/repos/HippoTeam/hippo/issues{/number}","pulls_url":"https://api.github.com/repos/HippoTeam/hippo/pulls{/number}","milestones_url":"https://api.github.com/repos/HippoTeam/hippo/milestones{/number}","notifications_url":"https://api.github.com/repos/HippoTeam/hippo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/HippoTeam/hippo/labels{/name}","releases_url":"https://api.github.com/repos/HippoTeam/hippo/releases{/id}","created_at":"2015-06-12T22:29:06Z","updated_at":"2015-06-15T21:59:00Z","pushed_at":"2015-06-15T23:34:10Z","git_url":"git://github.com/HippoTeam/hippo.git","ssh_url":"git@github.com:HippoTeam/hippo.git","clone_url":"https://github.com/HippoTeam/hippo.git","svn_url":"https://github.com/HippoTeam/hippo","homepage":null,"size":0,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":10,"forks":0,"open_issues":10,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/HippoTeam/hippo/pulls/24"},"html":{"href":"https://github.com/HippoTeam/hippo/pull/24"},"issue":{"href":"https://api.github.com/repos/HippoTeam/hippo/issues/24"},"comments":{"href":"https://api.github.com/repos/HippoTeam/hippo/issues/24/comments"},"review_comments":{"href":"https://api.github.com/repos/HippoTeam/hippo/pulls/24/comments"},"review_comment":{"href":"https://api.github.com/repos/HippoTeam/hippo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/HippoTeam/hippo/pulls/24/commits"},"statuses":{"href":"https://api.github.com/repos/HippoTeam/hippo/statuses/4de02cabcc98a96a133827497dc22c763c19dd30"}}}}