From 22fa48f2fc1c4d71d42eaed41ea1ef9af618d585 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Sat, 22 Apr 2017 09:26:18 +0900 Subject: Mixin `CollectionProxy::DelegateExtending` after `ClassSpecificRelation` `ClassSpecificRelation` has `method_missing` and the `method_missing` is called first. if an associated class has the missing method in a relation, never reach to the `method_missing` in the `CollectionProxy`. I extracted `DelegateExtending` and included it to the delegate class that including `ClassSpecificRelation` to fix the issue. Fixes https://github.com/rails/rails/pull/28246#issuecomment-296033784. --- activerecord/test/models/comment.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'activerecord/test/models') diff --git a/activerecord/test/models/comment.rb b/activerecord/test/models/comment.rb index a4b81d56e0..76b484e616 100644 --- a/activerecord/test/models/comment.rb +++ b/activerecord/test/models/comment.rb @@ -19,6 +19,11 @@ class Comment < ActiveRecord::Base has_many :children, class_name: "Comment", foreign_key: :parent_id belongs_to :parent, class_name: "Comment", counter_cache: :children_count + # Should not be called if extending modules that having the method exists on an association. + def self.greeting + raise + end + def self.what_are_you "a comment..." end -- cgit v1.2.3