Commit 72c560f6c0af0860388fd9e808c577ed90716401

Authored by MoisesMachado
1 parent d8b52907

ActionItem6: enterprise model updated

git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@178 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/models/enterprise.rb
@@ -2,17 +2,10 @@ @@ -2,17 +2,10 @@
2 class Enterprise < ActiveRecord::Base 2 class Enterprise < ActiveRecord::Base
3 3
4 after_create do |enterprise| 4 after_create do |enterprise|
5 - enterprise_profile = Profile.create(:identifier => enterprise.name) 5 + Profile.create!(:identifier => enterprise.name, :profile_owner_id => enterprise.id, :profile_owner_type => 'Enterprise')
6 end 6 end
7 7
8 has_one :enterprise_profile, :class_name => 'Profile', :as => :profile_owner 8 has_one :enterprise_profile, :class_name => 'Profile', :as => :profile_owner
9 9
10 - def name=(a_name)  
11 - enterprise_profile.name = a_name  
12 - end  
13 -  
14 - def name  
15 - enterprise_profile.name  
16 - end  
17 - 10 + validates_presence_of :name
18 end 11 end
db/migrate/007_create_enterprises.rb
1 class CreateEnterprises < ActiveRecord::Migration 1 class CreateEnterprises < ActiveRecord::Migration
2 def self.up 2 def self.up
3 create_table :enterprises do |t| 3 create_table :enterprises do |t|
  4 + t.column :name, :string
4 t.column :address, :string 5 t.column :address, :string
5 t.column :contact_phone, :string 6 t.column :contact_phone, :string
6 t.column :contact_person, :string 7 t.column :contact_person, :string