Commit 54abaf3e5882dae333416a19ecaf1d277292c519
1 parent
5ae25a69
Exists in
staging
and in
42 other branches
ActionItem6: Update relations
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@190 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
3 changed files
with
4 additions
and
12 deletions
Show diff stats
app/models/enterprise.rb
| 1 | 1 | #A enterprise is a kind of profile. According to the system concept, only enterprises can offer priducts/services |
| 2 | -class Enterprise < ActiveRecord::Base | |
| 2 | +class Enterprise < Profile | |
| 3 | 3 | |
| 4 | - after_create do |enterprise| | |
| 5 | - Profile.create!(:identifier => enterprise.name, :profile_owner_id => enterprise.id, :profile_owner_type => 'Enterprise') | |
| 6 | - end | |
| 7 | - | |
| 8 | - has_one :enterprise_profile, :class_name => 'Profile', :as => :profile_owner | |
| 9 | - has_many :affiliations | |
| 10 | - has_many :users, :through => :affiliations | |
| 11 | - belongs_to :manager, :class_name => 'User' | |
| 12 | - | |
| 13 | - validates_presence_of :name, :manager_id | |
| 14 | 4 | end | ... | ... |
app/models/profile.rb
| ... | ... | @@ -17,6 +17,8 @@ class Profile < ActiveRecord::Base |
| 17 | 17 | community |
| 18 | 18 | ] |
| 19 | 19 | |
| 20 | + has_many :affiliations | |
| 21 | + has_many :users, :through => :affiliations | |
| 20 | 22 | has_many :domains, :as => :owner |
| 21 | 23 | belongs_to :virtual_community |
| 22 | 24 | belongs_to :profile_owner, :polymorphic => true | ... | ... |
app/models/user.rb
| ... | ... | @@ -10,7 +10,7 @@ class User < ActiveRecord::Base |
| 10 | 10 | |
| 11 | 11 | has_one :personal_profile, :class_name => 'Profile', :as => :profile_owner |
| 12 | 12 | has_many :affiliations |
| 13 | - has_many :enterprises, :through => :affiliations | |
| 13 | + has_many :profiles, :through => :affiliations | |
| 14 | 14 | # Virtual attribute for the unencrypted password |
| 15 | 15 | attr_accessor :password |
| 16 | 16 | ... | ... |