{"action":"created","comment":{"url":"https://api.github.com/repos/rails/rails/pulls/comments/154274134","pull_request_review_id":80412242,"id":154274134,"diff_hunk":"@@ -100,10 +100,11 @@ def instantiate(attributes, column_types = {}, &block)\n       def update(id = :all, attributes)\n         if id.is_a?(Array)\n           id.map.with_index { |one_id, idx|\n-            object = find_by(primary_key => one_id)\n-            object.update(attributes[idx]) if object\n+            [ find(one_id), idx ]","path":"activerecord/lib/active_record/persistence.rb","position":6,"original_position":6,"commit_id":"3c8b9ad7777052dacf9a1a063200285b4d53ef21","original_commit_id":"3c8b9ad7777052dacf9a1a063200285b4d53ef21","user":{"login":"matthewd","id":1034,"avatar_url":"https://avatars1.githubusercontent.com/u/1034?v=4","gravatar_id":"","url":"https://api.github.com/users/matthewd","html_url":"https://github.com/matthewd","followers_url":"https://api.github.com/users/matthewd/followers","following_url":"https://api.github.com/users/matthewd/following{/other_user}","gists_url":"https://api.github.com/users/matthewd/gists{/gist_id}","starred_url":"https://api.github.com/users/matthewd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthewd/subscriptions","organizations_url":"https://api.github.com/users/matthewd/orgs","repos_url":"https://api.github.com/users/matthewd/repos","events_url":"https://api.github.com/users/matthewd/events{/privacy}","received_events_url":"https://api.github.com/users/matthewd/received_events","type":"User","site_admin":false},"body":"I think this one could also `find(id).each.with_index { |object, idx| object.update(attributes[idx]) }`\r\n\r\nNo real difference, but saves the explicit double-map.","created_at":"2017-12-01T06:10:49Z","updated_at":"2017-12-01T06:11:30Z","html_url":"https://github.com/rails/rails/pull/31306#discussion_r154274134","pull_request_url":"https://api.github.com/repos/rails/rails/pulls/31306","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/comments/154274134"},"html":{"href":"https://github.com/rails/rails/pull/31306#discussion_r154274134"},"pull_request":{"href":"https://api.github.com/repos/rails/rails/pulls/31306"}}},"pull_request":{"url":"https://api.github.com/repos/rails/rails/pulls/31306","id":155783579,"html_url":"https://github.com/rails/rails/pull/31306","diff_url":"https://github.com/rails/rails/pull/31306.diff","patch_url":"https://github.com/rails/rails/pull/31306.patch","issue_url":"https://api.github.com/repos/rails/rails/issues/31306","number":31306,"state":"open","locked":false,"title":"Class level `update` and `destroy` checks all the records exist before making changes","user":{"login":"kamipo","id":12642,"avatar_url":"https://avatars0.githubusercontent.com/u/12642?v=4","gravatar_id":"","url":"https://api.github.com/users/kamipo","html_url":"https://github.com/kamipo","followers_url":"https://api.github.com/users/kamipo/followers","following_url":"https://api.github.com/users/kamipo/following{/other_user}","gists_url":"https://api.github.com/users/kamipo/gists{/gist_id}","starred_url":"https://api.github.com/users/kamipo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kamipo/subscriptions","organizations_url":"https://api.github.com/users/kamipo/orgs","repos_url":"https://api.github.com/users/kamipo/repos","events_url":"https://api.github.com/users/kamipo/events{/privacy}","received_events_url":"https://api.github.com/users/kamipo/received_events","type":"User","site_admin":false},"body":"It makes more sense than ignoring invalid IDs.\r\n\r\ncc @matthewd ","created_at":"2017-12-01T05:02:28Z","updated_at":"2017-12-01T06:11:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b6e44777be6b116198e043325d308a4dc40c5a07","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/rails/rails/pulls/31306/commits","review_comments_url":"https://api.github.com/repos/rails/rails/pulls/31306/comments","review_comment_url":"https://api.github.com/repos/rails/rails/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rails/rails/issues/31306/comments","statuses_url":"https://api.github.com/repos/rails/rails/statuses/3c8b9ad7777052dacf9a1a063200285b4d53ef21","head":{"label":"kamipo:checking_all_records_exist_before_making_changes","ref":"checking_all_records_exist_before_making_changes","sha":"3c8b9ad7777052dacf9a1a063200285b4d53ef21","user":{"login":"kamipo","id":12642,"avatar_url":"https://avatars0.githubusercontent.com/u/12642?v=4","gravatar_id":"","url":"https://api.github.com/users/kamipo","html_url":"https://github.com/kamipo","followers_url":"https://api.github.com/users/kamipo/followers","following_url":"https://api.github.com/users/kamipo/following{/other_user}","gists_url":"https://api.github.com/users/kamipo/gists{/gist_id}","starred_url":"https://api.github.com/users/kamipo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kamipo/subscriptions","organizations_url":"https://api.github.com/users/kamipo/orgs","repos_url":"https://api.github.com/users/kamipo/repos","events_url":"https://api.github.com/users/kamipo/events{/privacy}","received_events_url":"https://api.github.com/users/kamipo/received_events","type":"User","site_admin":false},"repo":{"id":14544189,"name":"rails","full_name":"kamipo/rails","owner":{"login":"kamipo","id":12642,"avatar_url":"https://avatars0.githubusercontent.com/u/12642?v=4","gravatar_id":"","url":"https://api.github.com/users/kamipo","html_url":"https://github.com/kamipo","followers_url":"https://api.github.com/users/kamipo/followers","following_url":"https://api.github.com/users/kamipo/following{/other_user}","gists_url":"https://api.github.com/users/kamipo/gists{/gist_id}","starred_url":"https://api.github.com/users/kamipo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kamipo/subscriptions","organizations_url":"https://api.github.com/users/kamipo/orgs","repos_url":"https://api.github.com/users/kamipo/repos","events_url":"https://api.github.com/users/kamipo/events{/privacy}","received_events_url":"https://api.github.com/users/kamipo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kamipo/rails","description":"Ruby on Rails","fork":true,"url":"https://api.github.com/repos/kamipo/rails","forks_url":"https://api.github.com/repos/kamipo/rails/forks","keys_url":"https://api.github.com/repos/kamipo/rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kamipo/rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kamipo/rails/teams","hooks_url":"https://api.github.com/repos/kamipo/rails/hooks","issue_events_url":"https://api.github.com/repos/kamipo/rails/issues/events{/number}","events_url":"https://api.github.com/repos/kamipo/rails/events","assignees_url":"https://api.github.com/repos/kamipo/rails/assignees{/user}","branches_url":"https://api.github.com/repos/kamipo/rails/branches{/branch}","tags_url":"https://api.github.com/repos/kamipo/rails/tags","blobs_url":"https://api.github.com/repos/kamipo/rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kamipo/rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kamipo/rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/kamipo/rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kamipo/rails/statuses/{sha}","languages_url":"https://api.github.com/repos/kamipo/rails/languages","stargazers_url":"https://api.github.com/repos/kamipo/rails/stargazers","contributors_url":"https://api.github.com/repos/kamipo/rails/contributors","subscribers_url":"https://api.github.com/repos/kamipo/rails/subscribers","subscription_url":"https://api.github.com/repos/kamipo/rails/subscription","commits_url":"https://api.github.com/repos/kamipo/rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/kamipo/rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/kamipo/rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/kamipo/rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/kamipo/rails/contents/{+path}","compare_url":"https://api.github.com/repos/kamipo/rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kamipo/rails/merges","archive_url":"https://api.github.com/repos/kamipo/rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kamipo/rails/downloads","issues_url":"https://api.github.com/repos/kamipo/rails/issues{/number}","pulls_url":"https://api.github.com/repos/kamipo/rails/pulls{/number}","milestones_url":"https://api.github.com/repos/kamipo/rails/milestones{/number}","notifications_url":"https://api.github.com/repos/kamipo/rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kamipo/rails/labels{/name}","releases_url":"https://api.github.com/repos/kamipo/rails/releases{/id}","deployments_url":"https://api.github.com/repos/kamipo/rails/deployments","created_at":"2013-11-20T02:14:22Z","updated_at":"2015-02-16T07:18:13Z","pushed_at":"2017-12-01T05:00:37Z","git_url":"git://github.com/kamipo/rails.git","ssh_url":"git@github.com:kamipo/rails.git","clone_url":"https://github.com/kamipo/rails.git","svn_url":"https://github.com/kamipo/rails","homepage":"http://rubyonrails.org","size":146623,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rails:master","ref":"master","sha":"d041a1dcbaced9f44ed976a48312c9f492fffe5e","user":{"login":"rails","id":4223,"avatar_url":"https://avatars1.githubusercontent.com/u/4223?v=4","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"repo":{"id":8514,"name":"rails","full_name":"rails/rails","owner":{"login":"rails","id":4223,"avatar_url":"https://avatars1.githubusercontent.com/u/4223?v=4","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rails/rails","description":"Ruby on Rails","fork":false,"url":"https://api.github.com/repos/rails/rails","forks_url":"https://api.github.com/repos/rails/rails/forks","keys_url":"https://api.github.com/repos/rails/rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rails/rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rails/rails/teams","hooks_url":"https://api.github.com/repos/rails/rails/hooks","issue_events_url":"https://api.github.com/repos/rails/rails/issues/events{/number}","events_url":"https://api.github.com/repos/rails/rails/events","assignees_url":"https://api.github.com/repos/rails/rails/assignees{/user}","branches_url":"https://api.github.com/repos/rails/rails/branches{/branch}","tags_url":"https://api.github.com/repos/rails/rails/tags","blobs_url":"https://api.github.com/repos/rails/rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rails/rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rails/rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/rails/rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rails/rails/statuses/{sha}","languages_url":"https://api.github.com/repos/rails/rails/languages","stargazers_url":"https://api.github.com/repos/rails/rails/stargazers","contributors_url":"https://api.github.com/repos/rails/rails/contributors","subscribers_url":"https://api.github.com/repos/rails/rails/subscribers","subscription_url":"https://api.github.com/repos/rails/rails/subscription","commits_url":"https://api.github.com/repos/rails/rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/rails/rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/rails/rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/rails/rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/rails/rails/contents/{+path}","compare_url":"https://api.github.com/repos/rails/rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rails/rails/merges","archive_url":"https://api.github.com/repos/rails/rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rails/rails/downloads","issues_url":"https://api.github.com/repos/rails/rails/issues{/number}","pulls_url":"https://api.github.com/repos/rails/rails/pulls{/number}","milestones_url":"https://api.github.com/repos/rails/rails/milestones{/number}","notifications_url":"https://api.github.com/repos/rails/rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rails/rails/labels{/name}","releases_url":"https://api.github.com/repos/rails/rails/releases{/id}","deployments_url":"https://api.github.com/repos/rails/rails/deployments","created_at":"2008-04-11T02:19:47Z","updated_at":"2017-12-01T02:55:52Z","pushed_at":"2017-12-01T05:02:29Z","git_url":"git://github.com/rails/rails.git","ssh_url":"git@github.com:rails/rails.git","clone_url":"https://github.com/rails/rails.git","svn_url":"https://github.com/rails/rails","homepage":"http://rubyonrails.org","size":157570,"stargazers_count":37816,"watchers_count":37816,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":15405,"mirror_url":null,"archived":false,"open_issues_count":1110,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":15405,"open_issues":1110,"watchers":37816,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/31306"},"html":{"href":"https://github.com/rails/rails/pull/31306"},"issue":{"href":"https://api.github.com/repos/rails/rails/issues/31306"},"comments":{"href":"https://api.github.com/repos/rails/rails/issues/31306/comments"},"review_comments":{"href":"https://api.github.com/repos/rails/rails/pulls/31306/comments"},"review_comment":{"href":"https://api.github.com/repos/rails/rails/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rails/rails/pulls/31306/commits"},"statuses":{"href":"https://api.github.com/repos/rails/rails/statuses/3c8b9ad7777052dacf9a1a063200285b4d53ef21"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"matthewd"}}