Sha256: 270df60c43908977f11ca16b29d586cb29478062d1532fe56dcdf782d3915083
Contents?: true
Size: 543 Bytes
Versions: 1
Compression:
Stored size: 543 Bytes
Contents
module Forms class PersonForm < Kadmin::Form delegate_attributes :gender, :first_name, :last_name, :date_of_birth, :groups def initialize(*args) super raise(ArgumentError, 'Model given should be a person') unless @model.is_a?(Person) end validate :adult? def adult? cutoff_date = 18.years.ago.beginning_of_day if @model.date_of_birth >= cutoff_date @errors.add(:date_of_birth, :invalid, message: 'must be 18 years old') end end private :adult? end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kadmin-0.3.2 | test/dummy/lib/forms/person_form.rb |