{"action":"created","comment":{"url":"https://api.github.com/repos/ianlenehan/movienight-api/pulls/comments/85890106","pull_request_review_id":6576882,"id":85890106,"diff_hunk":"@@ -25,54 +23,54 @@ def group_events\n     end\n \n     def add_movie\n-      event = Event.find(params[:event_id])\n+      event_1 = Event.find(params[:event_id])\n       if event.update(imdb_id: params[:movie])\n-        render json: event, status: 201\n+        render json: event_1, status: 201\n       else\n-        render json: { errors: event.errors }, status: 422\n+        render json: { errors: event_1.errors }, status: 422\n       end\n     end\n \n     def attending\n-      event = Event.find(params[:event][:id])\n-      current_user = User.find_by(access_token: params[:user][:access_token])\n-      event.users << current_user\n+      event.users << user\n       render json: event.users\n     end\n \n     def not_attending\n-      event = Event.find(params[:event][:id])\n-      user = User.find_by(access_token: params[:user][:access_token])\n       event.users.delete(user)\n       render json: event.users\n     end\n \n     def add_rating\n-      event = Event.find(params[:event][:id])\n-      user = User.find_by(access_token: params[:user][:access_token])\n-      rating = params[:event][:rating]\n-      remove_rating(event, user) if user_has_already_rated(event, user)\n-      rating_record = Rating.create\n-      if rating_record.update(user_id: user.id, rating_score: rating, event_id: event.id)\n-        render json: rating_record\n-      else\n-        render json: { errors: rating_record.errors }\n-      end\n+      rating = Rating.find_or_initialize_by(user_id: user.id, event_id: event.id)\n+      rating.update(rating_score: params[:event][:rating])\n+      render json: rating\n     end\n \n     def show_rating\n-      event = Event.find(params[:id])\n-      user = User.find(params[:user_id])\n-      average = get_average_rating(event)\n-      if rating = find_rating(event, user)\n-        render json: { rating: rating, average: average }\n-      else\n-        render json: { rating: {rating_score: 0}, average: average }\n-      end\n+      event_1 = Event.find(params[:id])","path":"app/controllers/api/v1/events_controller.rb","position":70,"original_position":70,"commit_id":"08435e2f9751c42bd2c3c8da26670cb332dc01c5","original_commit_id":"1c055965a63b1c56f7dff776aa4b945d58d3f488","user":{"login":"Owenhorner","id":5653085,"avatar_url":"https://avatars.githubusercontent.com/u/5653085?v=3","gravatar_id":"","url":"https://api.github.com/users/Owenhorner","html_url":"https://github.com/Owenhorner","followers_url":"https://api.github.com/users/Owenhorner/followers","following_url":"https://api.github.com/users/Owenhorner/following{/other_user}","gists_url":"https://api.github.com/users/Owenhorner/gists{/gist_id}","starred_url":"https://api.github.com/users/Owenhorner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Owenhorner/subscriptions","organizations_url":"https://api.github.com/users/Owenhorner/orgs","repos_url":"https://api.github.com/users/Owenhorner/repos","events_url":"https://api.github.com/users/Owenhorner/events{/privacy}","received_events_url":"https://api.github.com/users/Owenhorner/received_events","type":"User","site_admin":false},"body":"I think the best option would be to send `params[:event][:id]` to be consistent with `event_params` wdyt?","created_at":"2016-11-01T08:30:33Z","updated_at":"2016-11-01T08:30:33Z","html_url":"https://github.com/ianlenehan/movienight-api/pull/1#discussion_r85890106","pull_request_url":"https://api.github.com/repos/ianlenehan/movienight-api/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/ianlenehan/movienight-api/pulls/comments/85890106"},"html":{"href":"https://github.com/ianlenehan/movienight-api/pull/1#discussion_r85890106"},"pull_request":{"href":"https://api.github.com/repos/ianlenehan/movienight-api/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/ianlenehan/movienight-api/pulls/1","id":91361263,"html_url":"https://github.com/ianlenehan/movienight-api/pull/1","diff_url":"https://github.com/ianlenehan/movienight-api/pull/1.diff","patch_url":"https://github.com/ianlenehan/movienight-api/pull/1.patch","issue_url":"https://api.github.com/repos/ianlenehan/movienight-api/issues/1","number":1,"state":"open","locked":false,"title":"moves event logic out of controller","user":{"login":"Owenhorner","id":5653085,"avatar_url":"https://avatars.githubusercontent.com/u/5653085?v=3","gravatar_id":"","url":"https://api.github.com/users/Owenhorner","html_url":"https://github.com/Owenhorner","followers_url":"https://api.github.com/users/Owenhorner/followers","following_url":"https://api.github.com/users/Owenhorner/following{/other_user}","gists_url":"https://api.github.com/users/Owenhorner/gists{/gist_id}","starred_url":"https://api.github.com/users/Owenhorner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Owenhorner/subscriptions","organizations_url":"https://api.github.com/users/Owenhorner/orgs","repos_url":"https://api.github.com/users/Owenhorner/repos","events_url":"https://api.github.com/users/Owenhorner/events{/privacy}","received_events_url":"https://api.github.com/users/Owenhorner/received_events","type":"User","site_admin":false},"body":"Moves a few methods out of the controller and into the event model\n","created_at":"2016-10-28T10:53:19Z","updated_at":"2016-11-01T08:30:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9b32f05c2179b49f85fc38e657d41abf5c024ed4","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/ianlenehan/movienight-api/pulls/1/commits","review_comments_url":"https://api.github.com/repos/ianlenehan/movienight-api/pulls/1/comments","review_comment_url":"https://api.github.com/repos/ianlenehan/movienight-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ianlenehan/movienight-api/issues/1/comments","statuses_url":"https://api.github.com/repos/ianlenehan/movienight-api/statuses/08435e2f9751c42bd2c3c8da26670cb332dc01c5","head":{"label":"Owenhorner:move_event_logic_out_of_controller","ref":"move_event_logic_out_of_controller","sha":"08435e2f9751c42bd2c3c8da26670cb332dc01c5","user":{"login":"Owenhorner","id":5653085,"avatar_url":"https://avatars.githubusercontent.com/u/5653085?v=3","gravatar_id":"","url":"https://api.github.com/users/Owenhorner","html_url":"https://github.com/Owenhorner","followers_url":"https://api.github.com/users/Owenhorner/followers","following_url":"https://api.github.com/users/Owenhorner/following{/other_user}","gists_url":"https://api.github.com/users/Owenhorner/gists{/gist_id}","starred_url":"https://api.github.com/users/Owenhorner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Owenhorner/subscriptions","organizations_url":"https://api.github.com/users/Owenhorner/orgs","repos_url":"https://api.github.com/users/Owenhorner/repos","events_url":"https://api.github.com/users/Owenhorner/events{/privacy}","received_events_url":"https://api.github.com/users/Owenhorner/received_events","type":"User","site_admin":false},"repo":{"id":72196723,"name":"movienight-api","full_name":"Owenhorner/movienight-api","owner":{"login":"Owenhorner","id":5653085,"avatar_url":"https://avatars.githubusercontent.com/u/5653085?v=3","gravatar_id":"","url":"https://api.github.com/users/Owenhorner","html_url":"https://github.com/Owenhorner","followers_url":"https://api.github.com/users/Owenhorner/followers","following_url":"https://api.github.com/users/Owenhorner/following{/other_user}","gists_url":"https://api.github.com/users/Owenhorner/gists{/gist_id}","starred_url":"https://api.github.com/users/Owenhorner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Owenhorner/subscriptions","organizations_url":"https://api.github.com/users/Owenhorner/orgs","repos_url":"https://api.github.com/users/Owenhorner/repos","events_url":"https://api.github.com/users/Owenhorner/events{/privacy}","received_events_url":"https://api.github.com/users/Owenhorner/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Owenhorner/movienight-api","description":null,"fork":true,"url":"https://api.github.com/repos/Owenhorner/movienight-api","forks_url":"https://api.github.com/repos/Owenhorner/movienight-api/forks","keys_url":"https://api.github.com/repos/Owenhorner/movienight-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Owenhorner/movienight-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Owenhorner/movienight-api/teams","hooks_url":"https://api.github.com/repos/Owenhorner/movienight-api/hooks","issue_events_url":"https://api.github.com/repos/Owenhorner/movienight-api/issues/events{/number}","events_url":"https://api.github.com/repos/Owenhorner/movienight-api/events","assignees_url":"https://api.github.com/repos/Owenhorner/movienight-api/assignees{/user}","branches_url":"https://api.github.com/repos/Owenhorner/movienight-api/branches{/branch}","tags_url":"https://api.github.com/repos/Owenhorner/movienight-api/tags","blobs_url":"https://api.github.com/repos/Owenhorner/movienight-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Owenhorner/movienight-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Owenhorner/movienight-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/Owenhorner/movienight-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Owenhorner/movienight-api/statuses/{sha}","languages_url":"https://api.github.com/repos/Owenhorner/movienight-api/languages","stargazers_url":"https://api.github.com/repos/Owenhorner/movienight-api/stargazers","contributors_url":"https://api.github.com/repos/Owenhorner/movienight-api/contributors","subscribers_url":"https://api.github.com/repos/Owenhorner/movienight-api/subscribers","subscription_url":"https://api.github.com/repos/Owenhorner/movienight-api/subscription","commits_url":"https://api.github.com/repos/Owenhorner/movienight-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/Owenhorner/movienight-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/Owenhorner/movienight-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/Owenhorner/movienight-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/Owenhorner/movienight-api/contents/{+path}","compare_url":"https://api.github.com/repos/Owenhorner/movienight-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Owenhorner/movienight-api/merges","archive_url":"https://api.github.com/repos/Owenhorner/movienight-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Owenhorner/movienight-api/downloads","issues_url":"https://api.github.com/repos/Owenhorner/movienight-api/issues{/number}","pulls_url":"https://api.github.com/repos/Owenhorner/movienight-api/pulls{/number}","milestones_url":"https://api.github.com/repos/Owenhorner/movienight-api/milestones{/number}","notifications_url":"https://api.github.com/repos/Owenhorner/movienight-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Owenhorner/movienight-api/labels{/name}","releases_url":"https://api.github.com/repos/Owenhorner/movienight-api/releases{/id}","deployments_url":"https://api.github.com/repos/Owenhorner/movienight-api/deployments","created_at":"2016-10-28T10:05:02Z","updated_at":"2016-10-28T10:05:03Z","pushed_at":"2016-11-01T08:19:52Z","git_url":"git://github.com/Owenhorner/movienight-api.git","ssh_url":"git@github.com:Owenhorner/movienight-api.git","clone_url":"https://github.com/Owenhorner/movienight-api.git","svn_url":"https://github.com/Owenhorner/movienight-api","homepage":null,"size":48,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ianlenehan:master","ref":"master","sha":"34a15909a0cf1685fa844b712e8af188ed9913f1","user":{"login":"ianlenehan","id":16395755,"avatar_url":"https://avatars.githubusercontent.com/u/16395755?v=3","gravatar_id":"","url":"https://api.github.com/users/ianlenehan","html_url":"https://github.com/ianlenehan","followers_url":"https://api.github.com/users/ianlenehan/followers","following_url":"https://api.github.com/users/ianlenehan/following{/other_user}","gists_url":"https://api.github.com/users/ianlenehan/gists{/gist_id}","starred_url":"https://api.github.com/users/ianlenehan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ianlenehan/subscriptions","organizations_url":"https://api.github.com/users/ianlenehan/orgs","repos_url":"https://api.github.com/users/ianlenehan/repos","events_url":"https://api.github.com/users/ianlenehan/events{/privacy}","received_events_url":"https://api.github.com/users/ianlenehan/received_events","type":"User","site_admin":false},"repo":{"id":71625584,"name":"movienight-api","full_name":"ianlenehan/movienight-api","owner":{"login":"ianlenehan","id":16395755,"avatar_url":"https://avatars.githubusercontent.com/u/16395755?v=3","gravatar_id":"","url":"https://api.github.com/users/ianlenehan","html_url":"https://github.com/ianlenehan","followers_url":"https://api.github.com/users/ianlenehan/followers","following_url":"https://api.github.com/users/ianlenehan/following{/other_user}","gists_url":"https://api.github.com/users/ianlenehan/gists{/gist_id}","starred_url":"https://api.github.com/users/ianlenehan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ianlenehan/subscriptions","organizations_url":"https://api.github.com/users/ianlenehan/orgs","repos_url":"https://api.github.com/users/ianlenehan/repos","events_url":"https://api.github.com/users/ianlenehan/events{/privacy}","received_events_url":"https://api.github.com/users/ianlenehan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ianlenehan/movienight-api","description":null,"fork":false,"url":"https://api.github.com/repos/ianlenehan/movienight-api","forks_url":"https://api.github.com/repos/ianlenehan/movienight-api/forks","keys_url":"https://api.github.com/repos/ianlenehan/movienight-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ianlenehan/movienight-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ianlenehan/movienight-api/teams","hooks_url":"https://api.github.com/repos/ianlenehan/movienight-api/hooks","issue_events_url":"https://api.github.com/repos/ianlenehan/movienight-api/issues/events{/number}","events_url":"https://api.github.com/repos/ianlenehan/movienight-api/events","assignees_url":"https://api.github.com/repos/ianlenehan/movienight-api/assignees{/user}","branches_url":"https://api.github.com/repos/ianlenehan/movienight-api/branches{/branch}","tags_url":"https://api.github.com/repos/ianlenehan/movienight-api/tags","blobs_url":"https://api.github.com/repos/ianlenehan/movienight-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ianlenehan/movienight-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ianlenehan/movienight-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/ianlenehan/movienight-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ianlenehan/movienight-api/statuses/{sha}","languages_url":"https://api.github.com/repos/ianlenehan/movienight-api/languages","stargazers_url":"https://api.github.com/repos/ianlenehan/movienight-api/stargazers","contributors_url":"https://api.github.com/repos/ianlenehan/movienight-api/contributors","subscribers_url":"https://api.github.com/repos/ianlenehan/movienight-api/subscribers","subscription_url":"https://api.github.com/repos/ianlenehan/movienight-api/subscription","commits_url":"https://api.github.com/repos/ianlenehan/movienight-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/ianlenehan/movienight-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/ianlenehan/movienight-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/ianlenehan/movienight-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/ianlenehan/movienight-api/contents/{+path}","compare_url":"https://api.github.com/repos/ianlenehan/movienight-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ianlenehan/movienight-api/merges","archive_url":"https://api.github.com/repos/ianlenehan/movienight-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ianlenehan/movienight-api/downloads","issues_url":"https://api.github.com/repos/ianlenehan/movienight-api/issues{/number}","pulls_url":"https://api.github.com/repos/ianlenehan/movienight-api/pulls{/number}","milestones_url":"https://api.github.com/repos/ianlenehan/movienight-api/milestones{/number}","notifications_url":"https://api.github.com/repos/ianlenehan/movienight-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ianlenehan/movienight-api/labels{/name}","releases_url":"https://api.github.com/repos/ianlenehan/movienight-api/releases{/id}","deployments_url":"https://api.github.com/repos/ianlenehan/movienight-api/deployments","created_at":"2016-10-22T08:05:32Z","updated_at":"2016-10-22T08:06:02Z","pushed_at":"2016-11-01T08:19:53Z","git_url":"git://github.com/ianlenehan/movienight-api.git","ssh_url":"git@github.com:ianlenehan/movienight-api.git","clone_url":"https://github.com/ianlenehan/movienight-api.git","svn_url":"https://github.com/ianlenehan/movienight-api","homepage":null,"size":49,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ianlenehan/movienight-api/pulls/1"},"html":{"href":"https://github.com/ianlenehan/movienight-api/pull/1"},"issue":{"href":"https://api.github.com/repos/ianlenehan/movienight-api/issues/1"},"comments":{"href":"https://api.github.com/repos/ianlenehan/movienight-api/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/ianlenehan/movienight-api/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/ianlenehan/movienight-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ianlenehan/movienight-api/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/ianlenehan/movienight-api/statuses/08435e2f9751c42bd2c3c8da26670cb332dc01c5"}}}}
{"actor":{"display_login":"Owenhorner"}}