Skip to content

Instantly share code, notes, and snippets.

@tochi
Last active July 27, 2019 01:50
Show Gist options
  • Save tochi/b24bb7e010dc3db0609eefa8b6ee4d4d to your computer and use it in GitHub Desktop.
Save tochi/b24bb7e010dc3db0609eefa8b6ee4d4d to your computer and use it in GitHub Desktop.
posts = post_ids.map.with_index(1) do |post_id, i|
post = Post.find(post_id)
post.title = "#{i}つめの記事です"
post
end
self.import(posts, on_duplicate_key_update: { conflict_target: %i(id), columns: %i(title)) })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment