{"action":"created","issue":{"url":"https://api.github.com/repos/ankane/strong_migrations/issues/2","repository_url":"https://api.github.com/repos/ankane/strong_migrations","labels_url":"https://api.github.com/repos/ankane/strong_migrations/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/ankane/strong_migrations/issues/2/comments","events_url":"https://api.github.com/repos/ankane/strong_migrations/issues/2/events","html_url":"https://github.com/ankane/strong_migrations/issues/2","id":149190680,"number":2,"title":"The structure of the `find_in_batches` example in README.md","user":{"login":"rkowalick","id":690440,"avatar_url":"https://avatars.githubusercontent.com/u/690440?v=3","gravatar_id":"","url":"https://api.github.com/users/rkowalick","html_url":"https://github.com/rkowalick","followers_url":"https://api.github.com/users/rkowalick/followers","following_url":"https://api.github.com/users/rkowalick/following{/other_user}","gists_url":"https://api.github.com/users/rkowalick/gists{/gist_id}","starred_url":"https://api.github.com/users/rkowalick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rkowalick/subscriptions","organizations_url":"https://api.github.com/users/rkowalick/orgs","repos_url":"https://api.github.com/users/rkowalick/repos","events_url":"https://api.github.com/users/rkowalick/events{/privacy}","received_events_url":"https://api.github.com/users/rkowalick/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-18T15:47:22Z","updated_at":"2016-05-21T01:05:31Z","closed_at":"2016-05-21T01:05:31Z","body":"Given that this gem is designed to prevent us all from shooting ourselves in the foot, I was curious why the example of backfilling a default column in the README.md was structured in this way:\r\n\r\n```ruby\r\nUser.find_in_batches do |users|\r\n  User.where(id: users.map(&:id)).update_all some_column: \"default_value\"\r\nend\r\n```\r\n\r\nThere seems to be some hidden knowledge in doing it this way vs. the simpler\r\n\r\n```ruby\r\nUser.find_in_batches do |users|\r\n  users.update_all some_column: \"default_value\"\r\nend\r\n```\r\n\r\nI was wondering if this is important in making good migrations, or if I could use the simpler version."},"comment":{"url":"https://api.github.com/repos/ankane/strong_migrations/issues/comments/220749890","html_url":"https://github.com/ankane/strong_migrations/issues/2#issuecomment-220749890","issue_url":"https://api.github.com/repos/ankane/strong_migrations/issues/2","id":220749890,"user":{"login":"rkowalick","id":690440,"avatar_url":"https://avatars.githubusercontent.com/u/690440?v=3","gravatar_id":"","url":"https://api.github.com/users/rkowalick","html_url":"https://github.com/rkowalick","followers_url":"https://api.github.com/users/rkowalick/followers","following_url":"https://api.github.com/users/rkowalick/following{/other_user}","gists_url":"https://api.github.com/users/rkowalick/gists{/gist_id}","starred_url":"https://api.github.com/users/rkowalick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rkowalick/subscriptions","organizations_url":"https://api.github.com/users/rkowalick/orgs","repos_url":"https://api.github.com/users/rkowalick/repos","events_url":"https://api.github.com/users/rkowalick/events{/privacy}","received_events_url":"https://api.github.com/users/rkowalick/received_events","type":"User","site_admin":false},"created_at":"2016-05-21T01:05:31Z","updated_at":"2016-05-21T01:05:31Z","body":"Actually resolved this issue with a discussion with a coworker: the block argument given in `find_in_batches` is not an ActiveRecord relation, but a Ruby array. In order to actually call `update_all`. you need to insure you have an activerecord relation, which is exactly what the `User.where(id: users.map(&:id))` is doing."}}
{"actor":{"display_login":"rkowalick"}}