From ce48b5a366482d4b4c4c053e1e39e79d71987197 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Sat, 15 Dec 2018 17:58:09 +0900 Subject: Prevent infinit method_missing loop on attribute methods If a klass has acceptance validation and then `klass.undefine_attribute_methods` is happened before an attribute method is called, infinit loop is caused on the `method_missing` defined by the `LazilyDefineAttributes`. https://travis-ci.org/rails/rails/jobs/467053984#L1409 To prevent the infinit loop, the `method_missing` should ensure `klass.define_attribute_methods`. --- activemodel/lib/active_model/validations/acceptance.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'activemodel') diff --git a/activemodel/lib/active_model/validations/acceptance.rb b/activemodel/lib/active_model/validations/acceptance.rb index ea3a6b52ab..9ff342d72b 100644 --- a/activemodel/lib/active_model/validations/acceptance.rb +++ b/activemodel/lib/active_model/validations/acceptance.rb @@ -54,6 +54,7 @@ module ActiveModel def define_on(klass) attr_readers = attributes.reject { |name| klass.attribute_method?(name) } attr_writers = attributes.reject { |name| klass.attribute_method?("#{name}=") } + klass.define_attribute_methods klass.send(:attr_reader, *attr_readers) klass.send(:attr_writer, *attr_writers) end -- cgit v1.2.3