osem-fcy/app/models/organization.rb

20 lines
456 B
Ruby
Raw Normal View History

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
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
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