Sha256: b2ef0331c7183b8b029986980d2b6fdbb4a31ae5515b56f642bbc9530717a96a

Contents?: true

Size: 473 Bytes

Versions: 23

Compression:

Stored size: 473 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, :group_ids

    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

23 entries across 23 versions & 1 rubygems

Version Path
egov_utils-1.4.1 app/models/egov_utils/registration_request.rb
egov_utils-1.4.0 app/models/egov_utils/registration_request.rb
egov_utils-1.3.0 app/models/egov_utils/registration_request.rb