Commit 3d47218e authored by Daniel Mack's avatar Daniel Mack Committed by Mario Manno

Person: nilify gender field if set to empty

For useful stats, it's important not to have a mixture of nil and "" in the
gender field of Person objects. Use an before_save callback to make sure we
always have nil instead of "".
parent d2c8a21d
......@@ -19,6 +19,8 @@ class Person < ActiveRecord::Base
belongs_to :user, dependent: :destroy
before_save :nilify_empty
acts_as_indexed fields: [:first_name, :last_name, :public_name, :email, :abstract, :description, :user_email]
has_paper_trail
......@@ -170,4 +172,8 @@ class Person < ActiveRecord::Base
self.event_people.select { |ep| ep.event.conference == conference }.select { |ep| ['speaker', 'moderator'].include? ep.event_role }
end
def nilify_empty
self.gender = nil if self.gender and self.gender.empty?
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment