{"action":"created","comment":{"url":"https://api.github.com/repos/renemaya/myflix/pulls/comments/42315382","id":42315382,"diff_hunk":"@@ -14,11 +14,38 @@ def create\n   def destroy\n     video = QueueItem.find_by id: params[:id]\n     destroy_queue_item(video)\n+    current_user.normalize_queue_item_positions\n+    redirect_to my_queue_path\n+  end\n+\n+  def update_queue\n+    begin\n+      update_queue_items\n+      current_user.normalize_queue_item_positions\n+    rescue ActiveRecord::RecordInvalid\n+      flash[:error] = \"Invalid position numbers.\"\n+    end\n+\n     redirect_to my_queue_path\n   end\n \n   private\n \n+  def update_queue_items\n+    ActiveRecord::Base.transaction do\n+      params[:queue_items].each do |queue_item_data|\n+        queue_item = QueueItem.find_by id: queue_item_data[:id]\n+\n+        if queue_item.user == current_user\n+          queue_item.update_attributes!(","path":"app/controllers/queue_items_controller.rb","position":27,"original_position":27,"commit_id":"447860ed92178090921f3f12c499230230be4c33","original_commit_id":"447860ed92178090921f3f12c499230230be4c33","user":{"login":"tomtomecek","id":7385469,"avatar_url":"https://avatars.githubusercontent.com/u/7385469?v=3","gravatar_id":"","url":"https://api.github.com/users/tomtomecek","html_url":"https://github.com/tomtomecek","followers_url":"https://api.github.com/users/tomtomecek/followers","following_url":"https://api.github.com/users/tomtomecek/following{/other_user}","gists_url":"https://api.github.com/users/tomtomecek/gists{/gist_id}","starred_url":"https://api.github.com/users/tomtomecek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomtomecek/subscriptions","organizations_url":"https://api.github.com/users/tomtomecek/orgs","repos_url":"https://api.github.com/users/tomtomecek/repos","events_url":"https://api.github.com/users/tomtomecek/events{/privacy}","received_events_url":"https://api.github.com/users/tomtomecek/received_events","type":"User","site_admin":false},"body":"You can use `update!` instead of `update_attributes!`. `update` is an alias for `update_attributes` since Rails 4.","created_at":"2015-10-17T23:44:03Z","updated_at":"2015-10-17T23:44:03Z","html_url":"https://github.com/renemaya/myflix/pull/4#discussion_r42315382","pull_request_url":"https://api.github.com/repos/renemaya/myflix/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/renemaya/myflix/pulls/comments/42315382"},"html":{"href":"https://github.com/renemaya/myflix/pull/4#discussion_r42315382"},"pull_request":{"href":"https://api.github.com/repos/renemaya/myflix/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/renemaya/myflix/pulls/4","id":47994194,"html_url":"https://github.com/renemaya/myflix/pull/4","diff_url":"https://github.com/renemaya/myflix/pull/4.diff","patch_url":"https://github.com/renemaya/myflix/pull/4.patch","issue_url":"https://api.github.com/repos/renemaya/myflix/issues/4","number":4,"state":"open","locked":false,"title":"Reorder and rate queue items","user":{"login":"renemaya","id":7717371,"avatar_url":"https://avatars.githubusercontent.com/u/7717371?v=3","gravatar_id":"","url":"https://api.github.com/users/renemaya","html_url":"https://github.com/renemaya","followers_url":"https://api.github.com/users/renemaya/followers","following_url":"https://api.github.com/users/renemaya/following{/other_user}","gists_url":"https://api.github.com/users/renemaya/gists{/gist_id}","starred_url":"https://api.github.com/users/renemaya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renemaya/subscriptions","organizations_url":"https://api.github.com/users/renemaya/orgs","repos_url":"https://api.github.com/users/renemaya/repos","events_url":"https://api.github.com/users/renemaya/events{/privacy}","received_events_url":"https://api.github.com/users/renemaya/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-17T20:06:28Z","updated_at":"2015-10-17T23:44:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d59d24148ba8cdb72e616a655b611ebe0f3e3093","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/renemaya/myflix/pulls/4/commits","review_comments_url":"https://api.github.com/repos/renemaya/myflix/pulls/4/comments","review_comment_url":"https://api.github.com/repos/renemaya/myflix/pulls/comments{/number}","comments_url":"https://api.github.com/repos/renemaya/myflix/issues/4/comments","statuses_url":"https://api.github.com/repos/renemaya/myflix/statuses/447860ed92178090921f3f12c499230230be4c33","head":{"label":"renemaya:reorder-and-rate-queue-items","ref":"reorder-and-rate-queue-items","sha":"447860ed92178090921f3f12c499230230be4c33","user":{"login":"renemaya","id":7717371,"avatar_url":"https://avatars.githubusercontent.com/u/7717371?v=3","gravatar_id":"","url":"https://api.github.com/users/renemaya","html_url":"https://github.com/renemaya","followers_url":"https://api.github.com/users/renemaya/followers","following_url":"https://api.github.com/users/renemaya/following{/other_user}","gists_url":"https://api.github.com/users/renemaya/gists{/gist_id}","starred_url":"https://api.github.com/users/renemaya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renemaya/subscriptions","organizations_url":"https://api.github.com/users/renemaya/orgs","repos_url":"https://api.github.com/users/renemaya/repos","events_url":"https://api.github.com/users/renemaya/events{/privacy}","received_events_url":"https://api.github.com/users/renemaya/received_events","type":"User","site_admin":false},"repo":{"id":43473476,"name":"myflix","full_name":"renemaya/myflix","owner":{"login":"renemaya","id":7717371,"avatar_url":"https://avatars.githubusercontent.com/u/7717371?v=3","gravatar_id":"","url":"https://api.github.com/users/renemaya","html_url":"https://github.com/renemaya","followers_url":"https://api.github.com/users/renemaya/followers","following_url":"https://api.github.com/users/renemaya/following{/other_user}","gists_url":"https://api.github.com/users/renemaya/gists{/gist_id}","starred_url":"https://api.github.com/users/renemaya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renemaya/subscriptions","organizations_url":"https://api.github.com/users/renemaya/orgs","repos_url":"https://api.github.com/users/renemaya/repos","events_url":"https://api.github.com/users/renemaya/events{/privacy}","received_events_url":"https://api.github.com/users/renemaya/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/renemaya/myflix","description":"","fork":false,"url":"https://api.github.com/repos/renemaya/myflix","forks_url":"https://api.github.com/repos/renemaya/myflix/forks","keys_url":"https://api.github.com/repos/renemaya/myflix/keys{/key_id}","collaborators_url":"https://api.github.com/repos/renemaya/myflix/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/renemaya/myflix/teams","hooks_url":"https://api.github.com/repos/renemaya/myflix/hooks","issue_events_url":"https://api.github.com/repos/renemaya/myflix/issues/events{/number}","events_url":"https://api.github.com/repos/renemaya/myflix/events","assignees_url":"https://api.github.com/repos/renemaya/myflix/assignees{/user}","branches_url":"https://api.github.com/repos/renemaya/myflix/branches{/branch}","tags_url":"https://api.github.com/repos/renemaya/myflix/tags","blobs_url":"https://api.github.com/repos/renemaya/myflix/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/renemaya/myflix/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/renemaya/myflix/git/refs{/sha}","trees_url":"https://api.github.com/repos/renemaya/myflix/git/trees{/sha}","statuses_url":"https://api.github.com/repos/renemaya/myflix/statuses/{sha}","languages_url":"https://api.github.com/repos/renemaya/myflix/languages","stargazers_url":"https://api.github.com/repos/renemaya/myflix/stargazers","contributors_url":"https://api.github.com/repos/renemaya/myflix/contributors","subscribers_url":"https://api.github.com/repos/renemaya/myflix/subscribers","subscription_url":"https://api.github.com/repos/renemaya/myflix/subscription","commits_url":"https://api.github.com/repos/renemaya/myflix/commits{/sha}","git_commits_url":"https://api.github.com/repos/renemaya/myflix/git/commits{/sha}","comments_url":"https://api.github.com/repos/renemaya/myflix/comments{/number}","issue_comment_url":"https://api.github.com/repos/renemaya/myflix/issues/comments{/number}","contents_url":"https://api.github.com/repos/renemaya/myflix/contents/{+path}","compare_url":"https://api.github.com/repos/renemaya/myflix/compare/{base}...{head}","merges_url":"https://api.github.com/repos/renemaya/myflix/merges","archive_url":"https://api.github.com/repos/renemaya/myflix/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/renemaya/myflix/downloads","issues_url":"https://api.github.com/repos/renemaya/myflix/issues{/number}","pulls_url":"https://api.github.com/repos/renemaya/myflix/pulls{/number}","milestones_url":"https://api.github.com/repos/renemaya/myflix/milestones{/number}","notifications_url":"https://api.github.com/repos/renemaya/myflix/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/renemaya/myflix/labels{/name}","releases_url":"https://api.github.com/repos/renemaya/myflix/releases{/id}","created_at":"2015-10-01T01:56:46Z","updated_at":"2015-10-02T05:39:55Z","pushed_at":"2015-10-17T20:06:28Z","git_url":"git://github.com/renemaya/myflix.git","ssh_url":"git@github.com:renemaya/myflix.git","clone_url":"https://github.com/renemaya/myflix.git","svn_url":"https://github.com/renemaya/myflix","homepage":null,"size":1392,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"renemaya:master","ref":"master","sha":"5cfb92fc9c39fd0b05f802567f2dede85c452fff","user":{"login":"renemaya","id":7717371,"avatar_url":"https://avatars.githubusercontent.com/u/7717371?v=3","gravatar_id":"","url":"https://api.github.com/users/renemaya","html_url":"https://github.com/renemaya","followers_url":"https://api.github.com/users/renemaya/followers","following_url":"https://api.github.com/users/renemaya/following{/other_user}","gists_url":"https://api.github.com/users/renemaya/gists{/gist_id}","starred_url":"https://api.github.com/users/renemaya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renemaya/subscriptions","organizations_url":"https://api.github.com/users/renemaya/orgs","repos_url":"https://api.github.com/users/renemaya/repos","events_url":"https://api.github.com/users/renemaya/events{/privacy}","received_events_url":"https://api.github.com/users/renemaya/received_events","type":"User","site_admin":false},"repo":{"id":43473476,"name":"myflix","full_name":"renemaya/myflix","owner":{"login":"renemaya","id":7717371,"avatar_url":"https://avatars.githubusercontent.com/u/7717371?v=3","gravatar_id":"","url":"https://api.github.com/users/renemaya","html_url":"https://github.com/renemaya","followers_url":"https://api.github.com/users/renemaya/followers","following_url":"https://api.github.com/users/renemaya/following{/other_user}","gists_url":"https://api.github.com/users/renemaya/gists{/gist_id}","starred_url":"https://api.github.com/users/renemaya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renemaya/subscriptions","organizations_url":"https://api.github.com/users/renemaya/orgs","repos_url":"https://api.github.com/users/renemaya/repos","events_url":"https://api.github.com/users/renemaya/events{/privacy}","received_events_url":"https://api.github.com/users/renemaya/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/renemaya/myflix","description":"","fork":false,"url":"https://api.github.com/repos/renemaya/myflix","forks_url":"https://api.github.com/repos/renemaya/myflix/forks","keys_url":"https://api.github.com/repos/renemaya/myflix/keys{/key_id}","collaborators_url":"https://api.github.com/repos/renemaya/myflix/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/renemaya/myflix/teams","hooks_url":"https://api.github.com/repos/renemaya/myflix/hooks","issue_events_url":"https://api.github.com/repos/renemaya/myflix/issues/events{/number}","events_url":"https://api.github.com/repos/renemaya/myflix/events","assignees_url":"https://api.github.com/repos/renemaya/myflix/assignees{/user}","branches_url":"https://api.github.com/repos/renemaya/myflix/branches{/branch}","tags_url":"https://api.github.com/repos/renemaya/myflix/tags","blobs_url":"https://api.github.com/repos/renemaya/myflix/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/renemaya/myflix/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/renemaya/myflix/git/refs{/sha}","trees_url":"https://api.github.com/repos/renemaya/myflix/git/trees{/sha}","statuses_url":"https://api.github.com/repos/renemaya/myflix/statuses/{sha}","languages_url":"https://api.github.com/repos/renemaya/myflix/languages","stargazers_url":"https://api.github.com/repos/renemaya/myflix/stargazers","contributors_url":"https://api.github.com/repos/renemaya/myflix/contributors","subscribers_url":"https://api.github.com/repos/renemaya/myflix/subscribers","subscription_url":"https://api.github.com/repos/renemaya/myflix/subscription","commits_url":"https://api.github.com/repos/renemaya/myflix/commits{/sha}","git_commits_url":"https://api.github.com/repos/renemaya/myflix/git/commits{/sha}","comments_url":"https://api.github.com/repos/renemaya/myflix/comments{/number}","issue_comment_url":"https://api.github.com/repos/renemaya/myflix/issues/comments{/number}","contents_url":"https://api.github.com/repos/renemaya/myflix/contents/{+path}","compare_url":"https://api.github.com/repos/renemaya/myflix/compare/{base}...{head}","merges_url":"https://api.github.com/repos/renemaya/myflix/merges","archive_url":"https://api.github.com/repos/renemaya/myflix/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/renemaya/myflix/downloads","issues_url":"https://api.github.com/repos/renemaya/myflix/issues{/number}","pulls_url":"https://api.github.com/repos/renemaya/myflix/pulls{/number}","milestones_url":"https://api.github.com/repos/renemaya/myflix/milestones{/number}","notifications_url":"https://api.github.com/repos/renemaya/myflix/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/renemaya/myflix/labels{/name}","releases_url":"https://api.github.com/repos/renemaya/myflix/releases{/id}","created_at":"2015-10-01T01:56:46Z","updated_at":"2015-10-02T05:39:55Z","pushed_at":"2015-10-17T20:06:28Z","git_url":"git://github.com/renemaya/myflix.git","ssh_url":"git@github.com:renemaya/myflix.git","clone_url":"https://github.com/renemaya/myflix.git","svn_url":"https://github.com/renemaya/myflix","homepage":null,"size":1392,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/renemaya/myflix/pulls/4"},"html":{"href":"https://github.com/renemaya/myflix/pull/4"},"issue":{"href":"https://api.github.com/repos/renemaya/myflix/issues/4"},"comments":{"href":"https://api.github.com/repos/renemaya/myflix/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/renemaya/myflix/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/renemaya/myflix/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/renemaya/myflix/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/renemaya/myflix/statuses/447860ed92178090921f3f12c499230230be4c33"}}}}