Module: Undestroyable::Orm::ActiveRecord::Column
- Defined in:
- lib/undestroyable/orm/active_record/column.rb
Overview
:column strategy is the easiest among the rest. It just updates :deleted_at column of the record, and set default scope conditions, to prevent its returning by default. Despite the record is actually just updated, no update callback will be triggered.
Example
class ConceptCat < ActiveRecord::Base
undstroyable do
startegy :column
end
end
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
17 18 19 |
# File 'lib/undestroyable/orm/active_record/column.rb', line 17 def self.included(base) base.send :default_scope, base.where('deleted_at IS NULL') end |
Instance Method Details
#destroy ⇒ Object
21 22 23 24 25 |
# File 'lib/undestroyable/orm/active_record/column.rb', line 21 def destroy run_callbacks :destroy do update_column :deleted_at, Time.now end end |