aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/comment.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-05-16 12:10:37 +0900
committerRyuta Kamizono <kamipo@gmail.com>2017-05-28 01:18:13 +0900
commit9b78974bc9f0dad0242d057b69f543471af2b92d (patch)
treefbc3922b2f0e6c708635e94fa9c449c09e6f03f1 /activerecord/test/models/comment.rb
parentfcc47bcfccc7578aa0414710eecdad006085a911 (diff)
downloadrails-9b78974bc9f0dad0242d057b69f543471af2b92d.tar.gz
rails-9b78974bc9f0dad0242d057b69f543471af2b92d.tar.bz2
rails-9b78974bc9f0dad0242d057b69f543471af2b92d.zip
Fix association with extension issues
This fixes the following issues. * `association_scope` doesn't include `default_scope`. Should use `scope` instead. * We can't use `method_missing` for customizing existing method. * We can't use `relation_delegate_class` for sharing extensions. Should extend per association.
Diffstat (limited to 'activerecord/test/models/comment.rb')
-rw-r--r--activerecord/test/models/comment.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/models/comment.rb b/activerecord/test/models/comment.rb
index 76b484e616..8cba788598 100644
--- a/activerecord/test/models/comment.rb
+++ b/activerecord/test/models/comment.rb
@@ -19,6 +19,16 @@ class Comment < ActiveRecord::Base
has_many :children, class_name: "Comment", foreign_key: :parent_id
belongs_to :parent, class_name: "Comment", counter_cache: :children_count
+ class ::OopsError < RuntimeError; end
+
+ module OopsExtension
+ def destroy_all(*)
+ raise OopsError
+ end
+ end
+
+ default_scope { extending OopsExtension }
+
# Should not be called if extending modules that having the method exists on an association.
def self.greeting
raise