Skip to content

Instantly share code, notes, and snippets.

@satomixx
Created March 31, 2015 02:27
Show Gist options
  • Save satomixx/ec43779cfc881fb84e92 to your computer and use it in GitHub Desktop.
Save satomixx/ec43779cfc881fb84e92 to your computer and use it in GitHub Desktop.
[Rails 4.x] bulk insertをupdateでもしたいときにはupdate_allがあります ref: http://qiita.com/tsumekoara/items/cf8cf3bbf296ecb8d2c7
gem 'activerecord-import'
# openがfalseのレコードをすべてtrueに変更したい
Shop.where(open: false).update_all(open: true)
# 全部のレコードをopen: trueに
Shop.update_all open: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment