Skip to content

Commit

Permalink
unify init logic
Browse files Browse the repository at this point in the history
  • Loading branch information
qinmingyuan committed Mar 6, 2024
1 parent 28b5ce0 commit 1e69a0d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app/models/growth/model/aim_log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ module Model::AimLog
validates :user_id, presence: true, if: -> { ip.blank? }
validates :ip, presence: true, if: -> { user_id.blank? }

before_validation if: :new_record? do
self.created_at = Time.now
self.serial_number = init_serial_number
end
before_validation :init_serial, if: :new_record?
before_create :init_aim_entity
after_create_commit :sync_aim_entity_state, :cache_entity_logs
end

def init_serial
self.serial_number = init_serial_number
end

def init_aim_entity
if self.user_id
if self.aim_entity
Expand Down

0 comments on commit 1e69a0d

Please sign in to comment.