Skip to content

Commit

Permalink
Changes to person model
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyshields committed Apr 21, 2024
1 parent 552a89c commit 041bb9e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions spec/support/models/name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ class Name
include Mongoid::Document
include Mongoid::Attributes::Dynamic

validate :is_not_jamis

field :_id, type: String, overwrite: true, default: lambda {
"#{first_name}-#{last_name}"
}
Expand All @@ -23,4 +25,11 @@ class Name
def set_parent=(set = false)
self.parent_title = namable.title if set
end

private

def is_not_jamis
return unless first_name == 'Jamis' && last_name == 'Buck'
errors.add(:base, :invalid)
end
end

0 comments on commit 041bb9e

Please sign in to comment.