Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/visual_migrate/activerecord.rb
Direct Known Subclasses
Class Method Summary collapse
Class Method Details
.update_or_create(attributes_array) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/visual_migrate/activerecord.rb', line 6 def update_or_create(attributes_array) attributes_array.each do |attributes| begin first = self.find(attributes[:id]) rescue end if first.nil? self.new(attributes).save else first.attributes = attributes first.save end end end |