Sha256: 11e8628038c25d6e28db6edc59bcf4fc400eeca34860befb59cab123e678bd38

Contents?: true

Size: 401 Bytes

Versions: 4

Compression:

Stored size: 401 Bytes

Contents

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

  encrypts :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

4 entries across 4 versions & 1 rubygems

Version Path
authtrail-0.4.2 lib/generators/authtrail/templates/model_lockbox.rb.tt
authtrail-0.4.1 lib/generators/authtrail/templates/model_lockbox.rb.tt
authtrail-0.4.0 lib/generators/authtrail/templates/model_lockbox.rb.tt
authtrail-0.3.1 lib/generators/authtrail/templates/model_lockbox.rb.tt