Removing projects, platforms and repositorits when owner removed.

Removing Relations joined with projects, platforms and repositories.
This commit is contained in:
George Vinogradov 2011-11-02 02:33:20 +04:00
parent 7bf87aa448
commit 3b72efcffd
3 changed files with 6 additions and 4 deletions

View File

@ -11,7 +11,7 @@ class Platform < ActiveRecord::Base
has_many :repositories, :dependent => :destroy
has_many :products, :dependent => :destroy
has_many :objects, :as => :target, :class_name => 'Relation'
has_many :objects, :as => :target, :class_name => 'Relation', :dependent => :destroy
has_many :members, :through => :objects, :source => :object, :source_type => 'User'
has_many :groups, :through => :objects, :source => :object, :source_type => 'Group'

View File

@ -5,9 +5,9 @@ class Repository < ActiveRecord::Base
belongs_to :owner, :polymorphic => true
has_many :projects, :through => :project_to_repositories #, :dependent => :destroy
has_many :project_to_repositories, :validate => true
has_many :project_to_repositories, :validate => true, :dependent => :destroy
has_many :objects, :as => :target, :class_name => 'Relation'
has_many :objects, :as => :target, :class_name => 'Relation', :dependent => :destroy
has_many :members, :through => :objects, :source => :object, :source_type => 'User'
has_many :groups, :through => :objects, :source => :object, :source_type => 'Group'

View File

@ -12,8 +12,10 @@ class User < ActiveRecord::Base
has_many :targets, :as => :object, :class_name => 'Relation'
has_many :own_projects, :as => :owner, :class_name => 'Project'
has_many :own_projects, :as => :owner, :class_name => 'Project', :dependent => :destroy
has_many :own_groups, :foreign_key => :owner_id, :class_name => 'Group'
has_many :own_platforms, :as => :owner, :class_name => 'Platform', :dependent => :destroy
has_many :own_repositories, :as => :owner, :class_name => 'Repository', :dependent => :destroy
has_many :groups, :through => :targets, :source => :target, :source_type => 'Group', :autosave => true
has_many :projects, :through => :targets, :source => :target, :source_type => 'Project', :autosave => true