新建组织后,增加默认栏目
This commit is contained in:
parent
692f13d1de
commit
527897bff0
|
@ -9,9 +9,15 @@ class Organization < ActiveRecord::Base
|
|||
has_many :org_subfields, :dependent => :destroy
|
||||
has_many :users, :through => :org_members
|
||||
validates_uniqueness_of :name
|
||||
after_create :save_as_org_activity
|
||||
after_create :save_as_org_activity, :add_default_subfields
|
||||
|
||||
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
|
||||
|
||||
def add_default_subfields
|
||||
OrgSubfield.create(:organization_id => self.id, :name => 'activity', :field_type => 'default')
|
||||
OrgSubfield.create(:organization_id => self.id, :name => 'course', :field_type => 'default')
|
||||
OrgSubfield.create(:organization_id => self.id, :name => 'project', :field_type => 'default')
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue