Skip to content
This repository has been archived by the owner on May 10, 2021. It is now read-only.

Commit

Permalink
move after_destroy callback to Recorder
Browse files Browse the repository at this point in the history
  • Loading branch information
y-yagi committed May 14, 2016
1 parent da12538 commit 50c9762
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 5 deletions.
2 changes: 2 additions & 0 deletions app/models/concerns/recorder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module Recorder
extend ActiveSupport::Concern

included do
after_destroy :record_deleted_datum

def record_deleted_datum
DeletedDatum.create!(table_name: self.class.table_name, datum_id: self.id, user_id: self.try(:user_id) || self.try(:owner_id))
end
Expand Down
2 changes: 0 additions & 2 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ class Event < ApplicationRecord
validates :name, presence: true, length: { maximum: 255 }
validates :detail, length: { maximum: 1024 }

after_destroy :record_deleted_datum

scope :future, -> do
where('end_date >= ?', Date.current)
end
Expand Down
2 changes: 0 additions & 2 deletions app/models/place.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ class Place < ActiveRecord::Base
validates :latitude, presence: true, if: -> { address.present? }
validates :longitude, presence: true, if: -> { address.present? }

after_destroy :record_deleted_datum

paginates_per 10

class << self
Expand Down
1 change: 0 additions & 1 deletion app/models/travel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class Travel < ActiveRecord::Base
end

before_save :adjust_travel_dates
after_destroy :record_deleted_datum

validates :name, presence: true, length: { maximum: 255 }
validates :start_date, presence: true
Expand Down

0 comments on commit 50c9762

Please sign in to comment.