[refs #143] fix destroy
This commit is contained in:
parent
4f17968b3b
commit
36f609ec7d
|
@ -4,14 +4,14 @@ class Group < ActiveRecord::Base
|
||||||
|
|
||||||
has_many :own_projects, :as => :owner, :class_name => 'Project'
|
has_many :own_projects, :as => :owner, :class_name => 'Project'
|
||||||
|
|
||||||
has_many :relations, :as => :object, :dependent => :destroy
|
|
||||||
has_many :objects, :as => :target, :class_name => 'Relation'
|
has_many :objects, :as => :target, :class_name => 'Relation'
|
||||||
has_many :targets, :as => :object, :class_name => 'Relation'
|
has_many :targets, :as => :object, :class_name => 'Relation'
|
||||||
|
|
||||||
has_many :members, :through => :objects, :source => :object, :source_type => 'User', :autosave => true
|
has_many :members, :through => :objects, :source => :object, :source_type => 'User', :autosave => true
|
||||||
has_many :projects, :through => :targets, :source => :target, :source_type => 'Project', :autosave => true
|
has_many :projects, :through => :targets, :source => :target, :source_type => 'Project', :autosave => true
|
||||||
has_many :platforms, :through => :targets, :source => :target, :source_type => 'Platform', :autosave => true
|
has_many :platforms, :through => :targets, :source => :target, :source_type => 'Platform', :autosave => true, :dependent => :destroy
|
||||||
has_many :repositories, :through => :targets, :source => :target, :source_type => 'Repository', :autosave => true
|
has_many :repositories, :through => :targets, :source => :target, :source_type => 'Repository', :autosave => true
|
||||||
|
has_many :relations, :as => :object, :dependent => :destroy
|
||||||
|
|
||||||
validates :name, :owner, :presence => true
|
validates :name, :owner, :presence => true
|
||||||
validates :uname, :presence => true, :uniqueness => {:case_sensitive => false}, :format => { :with => /^[a-z0-9_]+$/ }
|
validates :uname, :presence => true, :uniqueness => {:case_sensitive => false}, :format => { :with => /^[a-z0-9_]+$/ }
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
class RemoveOrphanPlatforms < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
Platform.all.each {|x| x.destroy unless x.owner.present?}
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue