diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index d86158b..72a148f 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -1,14 +1,4 @@ #A enterprise is a kind of profile. According to the system concept, only enterprises can offer priducts/services -class Enterprise < ActiveRecord::Base +class Enterprise < Profile - after_create do |enterprise| - Profile.create!(:identifier => enterprise.name, :profile_owner_id => enterprise.id, :profile_owner_type => 'Enterprise') - end - - has_one :enterprise_profile, :class_name => 'Profile', :as => :profile_owner - has_many :affiliations - has_many :users, :through => :affiliations - belongs_to :manager, :class_name => 'User' - - validates_presence_of :name, :manager_id end diff --git a/app/models/profile.rb b/app/models/profile.rb index bde2c30..150c5bf 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -17,6 +17,8 @@ class Profile < ActiveRecord::Base community ] + has_many :affiliations + has_many :users, :through => :affiliations has_many :domains, :as => :owner belongs_to :virtual_community belongs_to :profile_owner, :polymorphic => true diff --git a/app/models/user.rb b/app/models/user.rb index c5ef68a..a0b7995 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -10,7 +10,7 @@ class User < ActiveRecord::Base has_one :personal_profile, :class_name => 'Profile', :as => :profile_owner has_many :affiliations - has_many :enterprises, :through => :affiliations + has_many :profiles, :through => :affiliations # Virtual attribute for the unencrypted password attr_accessor :password -- libgit2 0.21.2