From 9ddf3eb1df80b04769540d05f68d73a4b8b1b7be Mon Sep 17 00:00:00 2001 From: MoisesMachado Date: Thu, 26 Jul 2007 20:40:43 +0000 Subject: [PATCH] ActionItem6: added association between users and enterprises --- app/models/enterprise.rb | 7 ++++--- app/models/user.rb | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) 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