Sha256: 78b9f2b4e1161bcf2038e55ef23f17be59d876460b3329420ff1981a3cc421bb

Contents?: true

Size: 455 Bytes

Versions: 2

Compression:

Stored size: 455 Bytes

Contents

# frozen_string_literal: true

#
# A mixin for models with secure fields.
# Basically if the secure field is blank, nil or "", then delete it from the update.
#
module SecureFields
  extend ActiveSupport::Concern
  #
  # Remove updates for secure fields
  #
  def update(params)
    secure_fields.each { |field| params.delete(field) if params[field].blank? }
    super(params)
  end

  #
  # List of secure fields
  #
  def secure_fields
    []
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
web47core-1.0.1 lib/app/models/concerns/secure_fields.rb
web47core-1.0.0 lib/app/models/concerns/seucre_fields.rb