socialforge/app/models/organization.rb

18 lines
796 B
Ruby

class Organization < ActiveRecord::Base
attr_accessible :name, :description, :creator_id, :home_id, :domain, :is_public
has_many :org_members, :dependent => :destroy
has_many :org_projects ,:dependent => :destroy
has_many :projects,:through => :org_projects
has_many :courses, :through => :org_courses
has_many :org_document_comments, :dependent => :destroy
has_many :org_courses, :dependent => :destroy
has_many :org_subfields, :dependent => :destroy
has_many :users, :through => :org_members
validates_uniqueness_of :name
after_create :save_as_org_activity
def save_as_org_activity
OrgActivity.create(:user_id => User.current.id, :org_act_id => self.id, :org_act_type => 'CreateOrganization', :container_id => self.id, :container_type => 'Organization')
end
end