From b4d4b80dcd5327d66a4d9c910fb9022c9dd93c4f Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Tue, 26 Dec 2006 17:11:44 +0000 Subject: [PATCH] replaced deprecated ":dependent => true" statements git-svn-id: http://redmine.rubyforge.org/svn/trunk@123 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/comment.rb | 17 +++++++++++++++++ app/models/custom_field.rb | 2 +- app/models/document.rb | 2 +- app/models/issue.rb | 7 +++---- app/models/journal.rb | 2 +- app/models/news.rb | 2 +- app/models/project.rb | 18 +++++++++--------- app/models/role.rb | 2 +- app/models/tracker.rb | 2 +- app/models/user.rb | 6 +++--- app/models/version.rb | 2 +- 11 files changed, 39 insertions(+), 23 deletions(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index 1ec7db630..27e5c511e 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -1,3 +1,20 @@ +# redMine - project management software +# Copyright (C) 2006 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + class Comment < ActiveRecord::Base belongs_to :commented, :polymorphic => true, :counter_cache => true belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb index 7dab23392..3626165b5 100644 --- a/app/models/custom_field.rb +++ b/app/models/custom_field.rb @@ -16,7 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class CustomField < ActiveRecord::Base - has_many :custom_values, :dependent => true + has_many :custom_values, :dependent => :delete_all FIELD_FORMATS = { "string" => { :name => :label_string, :order => 1 }, "text" => { :name => :label_text, :order => 2 }, diff --git a/app/models/document.rb b/app/models/document.rb index 08e0ef607..40a9765a4 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -18,7 +18,7 @@ class Document < ActiveRecord::Base belongs_to :project belongs_to :category, :class_name => "Enumeration", :foreign_key => "category_id" - has_many :attachments, :as => :container, :dependent => true + has_many :attachments, :as => :container, :dependent => :destroy validates_presence_of :project, :title, :category end diff --git a/app/models/issue.rb b/app/models/issue.rb index f00eb7a9c..6f77bef30 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -26,11 +26,10 @@ class Issue < ActiveRecord::Base belongs_to :priority, :class_name => 'Enumeration', :foreign_key => 'priority_id' belongs_to :category, :class_name => 'IssueCategory', :foreign_key => 'category_id' - #has_many :histories, :class_name => 'IssueHistory', :dependent => true, :order => "issue_histories.created_on DESC", :include => :status - has_many :journals, :as => :journalized, :dependent => true - has_many :attachments, :as => :container, :dependent => true + has_many :journals, :as => :journalized, :dependent => :destroy + has_many :attachments, :as => :container, :dependent => :destroy - has_many :custom_values, :dependent => true, :as => :customized + has_many :custom_values, :dependent => :delete_all, :as => :customized has_many :custom_fields, :through => :custom_values validates_presence_of :subject, :description, :priority, :tracker, :author, :status diff --git a/app/models/journal.rb b/app/models/journal.rb index 9d173552f..18a6ec083 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -18,5 +18,5 @@ class Journal < ActiveRecord::Base belongs_to :journalized, :polymorphic => true belongs_to :user - has_many :details, :class_name => "JournalDetail", :dependent => true + has_many :details, :class_name => "JournalDetail", :dependent => :delete_all end diff --git a/app/models/news.rb b/app/models/news.rb index f9ba010b0..0083a0eae 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -18,7 +18,7 @@ class News < ActiveRecord::Base belongs_to :project belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' - has_many :comments, :as => :commented, :dependent => true, :order => "created_on" + has_many :comments, :as => :commented, :dependent => :delete_all, :order => "created_on" validates_presence_of :title, :description diff --git a/app/models/project.rb b/app/models/project.rb index 5f15ad6f6..1fc2cffa1 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -16,16 +16,16 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class Project < ActiveRecord::Base - has_many :versions, :dependent => true, :order => "versions.effective_date DESC, versions.name DESC" - has_many :members, :dependent => true, :include => :user, :conditions => "users.status=#{User::STATUS_ACTIVE}" + has_many :versions, :dependent => :destroy, :order => "versions.effective_date DESC, versions.name DESC" + has_many :members, :dependent => :delete_all, :include => :user, :conditions => "users.status=#{User::STATUS_ACTIVE}" has_many :users, :through => :members - has_many :custom_values, :dependent => true, :as => :customized - has_many :issues, :dependent => true, :order => "issues.created_on DESC", :include => [:status, :tracker] - has_many :queries, :dependent => true - has_many :documents, :dependent => true - has_many :news, :dependent => true, :include => :author - has_many :issue_categories, :dependent => true, :order => "issue_categories.name" - has_one :repository, :dependent => true + has_many :custom_values, :dependent => :delete_all, :as => :customized + has_many :issues, :dependent => :destroy, :order => "issues.created_on DESC", :include => [:status, :tracker] + has_many :queries, :dependent => :delete_all + has_many :documents, :dependent => :destroy + has_many :news, :dependent => :delete_all, :include => :author + has_many :issue_categories, :dependent => :delete_all, :order => "issue_categories.name" + has_one :repository, :dependent => :destroy has_and_belongs_to_many :custom_fields, :class_name => 'IssueCustomField', :join_table => 'custom_fields_projects', :association_foreign_key => 'custom_field_id' acts_as_tree :order => "name", :counter_cache => true diff --git a/app/models/role.rb b/app/models/role.rb index 4761b75ad..aea402f46 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -18,7 +18,7 @@ class Role < ActiveRecord::Base before_destroy :check_integrity has_and_belongs_to_many :permissions - has_many :workflows, :dependent => true + has_many :workflows, :dependent => :delete_all has_many :members validates_presence_of :name diff --git a/app/models/tracker.rb b/app/models/tracker.rb index 041525f0f..8790bf725 100644 --- a/app/models/tracker.rb +++ b/app/models/tracker.rb @@ -18,7 +18,7 @@ class Tracker < ActiveRecord::Base before_destroy :check_integrity has_many :issues - has_many :workflows, :dependent => true + has_many :workflows, :dependent => :delete_all has_and_belongs_to_many :custom_fields, :class_name => 'IssueCustomField', :join_table => 'custom_fields_trackers', :association_foreign_key => 'custom_field_id' validates_presence_of :name diff --git a/app/models/user.rb b/app/models/user.rb index 0287006c6..b798860d2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -18,10 +18,10 @@ require "digest/sha1" class User < ActiveRecord::Base - has_many :memberships, :class_name => 'Member', :include => [ :project, :role ], :dependent => true + has_many :memberships, :class_name => 'Member', :include => [ :project, :role ], :dependent => :delete_all has_many :projects, :through => :memberships - has_many :custom_values, :dependent => true, :as => :customized - has_one :preference, :dependent => true, :class_name => 'UserPreference' + has_many :custom_values, :dependent => :delete_all, :as => :customized + has_one :preference, :dependent => :destroy, :class_name => 'UserPreference' belongs_to :auth_source attr_accessor :password, :password_confirmation diff --git a/app/models/version.rb b/app/models/version.rb index 0ae1edda8..71a8a8807 100644 --- a/app/models/version.rb +++ b/app/models/version.rb @@ -19,7 +19,7 @@ class Version < ActiveRecord::Base before_destroy :check_integrity belongs_to :project has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id' - has_many :attachments, :as => :container, :dependent => true + has_many :attachments, :as => :container, :dependent => :destroy validates_presence_of :name validates_uniqueness_of :name, :scope => [:project_id]