Module: ActsAsArchive::Base::Restore::ClassMethods
- Defined in:
- lib/acts_as_archive/base/restore.rb
Instance Method Summary collapse
Instance Method Details
#copy_from_archive(conditions) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/acts_as_archive/base/restore.rb', line 14 def copy_from_archive(conditions) add_conditions!(where = '', conditions) col_names = column_names - [ 'deleted_at' ] col_names.map! { |col| connection.quote_column_name(col) } connection.execute(%{ INSERT INTO #{table_name} (#{col_names.join(', ')}) SELECT #{col_names.join(', ')} FROM archived_#{table_name} #{where} }) connection.execute("DELETE FROM archived_#{table_name} #{where}") end |
#restore_all(conditions = nil) ⇒ Object
27 28 29 |
# File 'lib/acts_as_archive/base/restore.rb', line 27 def restore_all(conditions=nil) copy_from_archive(conditions) end |