Commit 9ddf3eb1df80b04769540d05f68d73a4b8b1b7be

Authored by MoisesMachado
1 parent d07e4225

ActionItem6: added association between users and enterprises

git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@183 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing 2 changed files with 6 additions and 4 deletions   Show diff stats
app/models/enterprise.rb
... ... @@ -6,7 +6,8 @@ class Enterprise < ActiveRecord::Base
6 6 end
7 7  
8 8 has_one :enterprise_profile, :class_name => 'Profile', :as => :profile_owner
9   - has_many :users
10   -
11   - validates_presence_of :name
  9 + has_many :users, :through => :affiliation
  10 + belongs_to :manager, :class_name => 'User'
  11 +
  12 + validates_presence_of :name, :manager_id
12 13 end
... ...
app/models/user.rb
... ... @@ -9,7 +9,8 @@ class User < ActiveRecord::Base
9 9 end
10 10  
11 11 has_one :personal_profile, :class_name => 'Profile', :as => :profile_owner
12   -
  12 + has_many :affiliations
  13 + has_many :enterprises, :through => :affiliation
13 14 # Virtual attribute for the unencrypted password
14 15 attr_accessor :password
15 16  
... ...