aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2010-03-07 21:53:21 -0300
committerJosé Valim <jose.valim@gmail.com>2010-03-09 00:11:34 +0100
commit47d252f9928568620844edce2161acd457c352c0 (patch)
treed8dce8dbd2c2c973bd792a51dafbc9d0c430a1c3 /activerecord/test/models
parent8e9d9232b0c3d96c662762e13848c275a86c0c61 (diff)
downloadrails-47d252f9928568620844edce2161acd457c352c0.tar.gz
rails-47d252f9928568620844edce2161acd457c352c0.tar.bz2
rails-47d252f9928568620844edce2161acd457c352c0.zip
Fix associations to call :destroy or :delete based on the right :dependent option
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord/test/models')
-rw-r--r--activerecord/test/models/author.rb9
-rw-r--r--activerecord/test/models/company.rb4
2 files changed, 5 insertions, 8 deletions
diff --git a/activerecord/test/models/author.rb b/activerecord/test/models/author.rb
index 7cbc6e803f..025f6207f8 100644
--- a/activerecord/test/models/author.rb
+++ b/activerecord/test/models/author.rb
@@ -35,7 +35,7 @@ class Author < ActiveRecord::Base
has_many :ordered_uniq_comments, :through => :posts, :source => :comments, :uniq => true, :order => 'comments.id'
has_many :ordered_uniq_comments_desc, :through => :posts, :source => :comments, :uniq => true, :order => 'comments.id DESC'
has_many :readonly_comments, :through => :posts, :source => :comments, :readonly => true
-
+
has_many :special_posts
has_many :special_post_comments, :through => :special_posts, :source => :comments
@@ -130,14 +130,11 @@ class AuthorAddress < ActiveRecord::Base
has_one :author
def self.destroyed_author_address_ids
- @destroyed_author_address_ids ||= Hash.new { |h,k| h[k] = [] }
+ @destroyed_author_address_ids ||= []
end
before_destroy do |author_address|
- if author_address.author
- AuthorAddress.destroyed_author_address_ids[author_address.author.id] << author_address.id
- end
- true
+ AuthorAddress.destroyed_author_address_ids << author_address.id
end
end
diff --git a/activerecord/test/models/company.rb b/activerecord/test/models/company.rb
index df5fd10b6b..f31d5f87e5 100644
--- a/activerecord/test/models/company.rb
+++ b/activerecord/test/models/company.rb
@@ -82,7 +82,7 @@ class Firm < Company
has_one :account_using_primary_key, :primary_key => "firm_id", :class_name => "Account", :order => "id"
has_one :account_using_foreign_and_primary_keys, :foreign_key => "firm_name", :primary_key => "name", :class_name => "Account"
has_one :deletable_account, :foreign_key => "firm_id", :class_name => "Account", :dependent => :delete
-
+
has_one :account_limit_500_with_hash_conditions, :foreign_key => "firm_id", :class_name => "Account", :conditions => { :credit_limit => 500 }
has_one :unautosaved_account, :foreign_key => "firm_id", :class_name => 'Account', :autosave => false
@@ -155,7 +155,7 @@ class VerySpecialClient < SpecialClient
end
class Account < ActiveRecord::Base
- belongs_to :firm
+ belongs_to :firm, :class_name => 'Company'
belongs_to :unautosaved_firm, :foreign_key => "firm_id", :class_name => "Firm", :autosave => false
def self.destroyed_account_ids