Sha256: 9f5c4b775928b00605c4744d71ff69e1a347d03ddcce147372aff7fcd48a9cc7

Contents?: true

Size: 756 Bytes

Versions: 4

Compression:

Stored size: 756 Bytes

Contents

class Registration < ApplicationRecord
	has_many :known_prog_languages
	has_many :prog_languages, -> { distinct }, through: :known_prog_languages
	
	

	validates :first_name, :last_name, :email, presence: true
	validates :age, numericality: { greater_than_or_equal_to: 21 }
	validate  :dob_in_past
	validates :sex, presence: true
	has_one :address
	accepts_nested_attributes_for :address
	validates :favorite_color, format: { without: /\A#(000000|FFFFFF)\z/i }
	validates :prog_language_ids, presence: true
	validates :accept_terms, acceptance: { accept: true }

	def kpl_selections
		known_prog_languages.pluck(:prog_language_id)
	end

	private
	def dob_in_past
		errors.add(:date_of_birth, "must be in the past")	unless date_of_birth < Time.now
	end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
emphatic_invalids-0.1.2 test/dummy/app/models/registration.rb
emphatic_invalids-0.0.1 test/dummy/app/models/registration.rb
emphatic_invalids-0.1.1 test/dummy/app/models/registration.rb
emphatic_invalids-0.1.0 test/dummy/app/models/registration.rb