agenda-libre-ruby/app/models/orga.rb

22 lines
653 B
Ruby

# Groups related to this agenda
class Orga < ActiveRecord::Base
belongs_to :region
belongs_to :kind
validates :kind, presence: true
validates :name, presence: true
validates :region, presence: true
validates :url, format: %r{\Ahttps?:\/\/.*\..*\z}
validates :feed, allow_blank: true, format: %r{\Ahttps?:\/\/.*\..*\z}
validates :contact, allow_blank: true, email: true
validates :submitter, allow_blank: true, email: true
before_validation on: :create do
self.submission_time = Time.zone.now
self.decision_time = Time.zone.now
# Populate submitter using contact info if absent
self.submitter ||= contact
end
end