osem-fcy/app/models/organization.rb

26 lines
578 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class Organization < ApplicationRecord
2017-06-13 04:39:47 +05:30
resourcify :roles, dependent: :delete_all
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
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
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