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
|
|
|
|
|
|
2017-05-31 18:42:52 +05:30
|
|
|
validates :name, presence: true
|
|
|
|
|
|
|
|
|
|
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
|