2018-05-07 16:47:29 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2017-09-05 22:23:34 +03:00
|
|
|
class Organization < ApplicationRecord
|
2017-06-13 04:39:47 +05:30
|
|
|
resourcify :roles, dependent: :delete_all
|
|
|
|
|
|
2017-08-23 19:53:35 +05:30
|
|
|
has_paper_trail
|
|
|
|
|
|
2017-06-06 20:04:39 +05:30
|
|
|
has_many :conferences, dependent: :destroy
|
2017-05-31 18:42:52 +05:30
|
|
|
|
2017-06-13 04:39:47 +05:30
|
|
|
after_create :create_roles
|
|
|
|
|
|
2018-01-15 22:14:22 -06:00
|
|
|
validates :name,
|
|
|
|
|
uniqueness: {
|
|
|
|
|
case_sensitive: false
|
|
|
|
|
},
|
2018-11-13 18:01:49 -08:00
|
|
|
presence: true
|
2017-05-31 18:42:52 +05:30
|
|
|
|
|
|
|
|
mount_uploader :picture, PictureUploader, mount_on: :picture
|
2017-06-13 04:39:47 +05:30
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def create_roles
|
2017-06-14 22:51:26 +05:30
|
|
|
roles.where(name: 'organization_admin').first_or_create(description: 'For the administrators of an organization and its conferences')
|
2017-06-13 04:39:47 +05:30
|
|
|
end
|
2017-05-31 18:42:52 +05:30
|
|
|
end
|