This is useful if you're writing a migration wherein a model might be deleted by the time the migration runs:


ActiveRecord::Base.connection.execute("SELECT * from old_table_name").all.each do |record|
# `record` is a hash of string attributes for each column in the table
NewModel.create(record.symbolize_keys.slice(:name, :title))
end