Sha256: 4b1b37665656189f777f18b5cdd678a01aca28d6224bde1054271097ad483ac7

Contents?: true

Size: 461 Bytes

Versions: 4

Compression:

Stored size: 461 Bytes

Contents

module EgovUtils
  class RegistrationRequest < ApplicationRecord
    validates :mail, :firstname, :lastname, :organization, :supervisor_email,
              :supervisor_name, presence: true
    validate :check_user_already_exists!

    attr_accessor :roles

    def fullname
      "#{firstname} #{lastname}"
    end

    private

    def check_user_already_exists!
      return unless User.find_by(mail: mail)

      errors.add(:mail, :taken)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
egov_utils-1.2.4 app/models/egov_utils/registration_request.rb
egov_utils-1.2.3 app/models/egov_utils/registration_request.rb
egov_utils-1.2.2 app/models/egov_utils/registration_request.rb
egov_utils-1.2.1 app/models/egov_utils/registration_request.rb