Method: Array#to_upsert_sql
- Defined in:
- lib/crudboy/ext/array.rb
#to_upsert_sql(batch_size = 500) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/crudboy/ext/array.rb', line 9 def to_upsert_sql(batch_size=500) raise 'All element should be an ActiveRecord instance object' unless all? { |e| e.is_a?(ActiveRecord::Base) } group_by(&:class).map do |(klass, records)| klass.to_upsert_sql(records, batch_size) end.join("\n") end |