0

I have a table that i need to add a new field and copy the value into another field. Now this table has way to many records so i can just loop on each record and update it one at the time.

What would be the best way to do this.

My DB is PG but i would really like a Activerecord way of doing this

MZaragoza
  • 10,108
  • 9
  • 71
  • 116

1 Answers1

1

YourTable.update_all('new_field_name = old_field_name')

see http://apidock.com/rails/ActiveRecord/Base/update_all/class

Mark Bolusmjak
  • 23,606
  • 10
  • 74
  • 129