Skip to content

Commit

Permalink
set email to nil instead of an empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
kf8a committed Aug 12, 2024
1 parent a68e4e6 commit b400dec
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/models/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Represents a person in the system
class Person < ApplicationRecord
has_many :affiliations, dependent: :destroy
has_many :lter_roles, -> { where(['role_type_id = ?', RoleType.find_by(name: 'lter')]) },
has_many :lter_affiliations, -> { where(['role_type_id = ?', RoleType.find_by(name: 'lter')]) },
source: :role, through: :affiliations
has_many :lno_roles, -> { where(['role_type_id = ?', RoleType.find_by(name: 'lno')]) },
source: :role, through: :affiliations
Expand All @@ -20,6 +20,7 @@ class Person < ApplicationRecord
has_many :datatables, through: :data_contributions

accepts_nested_attributes_for :affiliations, allow_destroy: true
accepts_nested_attributes_for :lter_affiliations, allow_destroy: true

scope :by_sur_name, -> { order 'sur_name' }
scope :by_sur_name_asc, -> { order 'sur_name ASC' }
Expand Down Expand Up @@ -64,6 +65,10 @@ def usa_address?
country.blank? || country.casecmp('usa').zero? || country.casecmp('us').zero?
end

def email=(val)
super(val == "" ? nil : val)
end

def complete_address?
!usa_address? ||
(city.present? && street_address.present? &&
Expand Down

0 comments on commit b400dec

Please sign in to comment.