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

22 lines
651 B
Ruby
Raw Normal View History

# Groups related to this agenda
2015-02-15 17:10:17 +01:00
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 = DateTime.now
self.decision_time = DateTime.now
# Populate submitter using contact info if absent
self.submitter ||= contact
end
end