diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index b9af976..e443105 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -6,7 +6,8 @@ class Enterprise < ActiveRecord::Base end has_one :enterprise_profile, :class_name => 'Profile', :as => :profile_owner - has_many :users - - validates_presence_of :name + has_many :users, :through => :affiliation + belongs_to :manager, :class_name => 'User' + + validates_presence_of :name, :manager_id end diff --git a/app/models/user.rb b/app/models/user.rb index 455d5ab..7b1a9ff 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -9,7 +9,8 @@ class User < ActiveRecord::Base end has_one :personal_profile, :class_name => 'Profile', :as => :profile_owner - + has_many :affiliations + has_many :enterprises, :through => :affiliation # Virtual attribute for the unencrypted password attr_accessor :password -- libgit2 0.21.2