diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-12-15 17:58:09 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2018-12-15 18:07:13 +0900 |
commit | ce48b5a366482d4b4c4c053e1e39e79d71987197 (patch) | |
tree | ec6c896a4f279206deede9281d64a5985f8a52fb /activemodel | |
parent | d57841b5c453370598f00dccd68000ae18c9ef58 (diff) | |
download | rails-ce48b5a366482d4b4c4c053e1e39e79d71987197.tar.gz rails-ce48b5a366482d4b4c4c053e1e39e79d71987197.tar.bz2 rails-ce48b5a366482d4b4c4c053e1e39e79d71987197.zip |
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`.
Diffstat (limited to 'activemodel')
-rw-r--r-- | activemodel/lib/active_model/validations/acceptance.rb | 1 |
1 files changed, 1 insertions, 0 deletions
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 |