Sha256: 1010d0534632668964b5202f026e5a3379834ee05eb934510775f402ccd7a0e8

Contents?: true

Size: 414 Bytes

Versions: 3

Compression:

Stored size: 414 Bytes

Contents

class LoginActivity < ApplicationRecord
  belongs_to :user, polymorphic: true, optional: true

  <%= lockbox_method %> :identity, :ip
  blind_index :identity, :ip

  before_save :reduce_precision

  # reduce precision to city level to protect IP
  def reduce_precision
    self.latitude = latitude&.round(1) if try(:latitude_changed?)
    self.longitude = longitude&.round(1) if try(:longitude_changed?)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
authtrail-0.6.0 lib/generators/authtrail/templates/model_lockbox.rb.tt
authtrail-0.5.0 lib/generators/authtrail/templates/model_lockbox.rb.tt
authtrail-0.4.3 lib/generators/authtrail/templates/model_lockbox.rb.tt