aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2015-01-05 14:45:14 -0700
committerSean Griffin <sean@thoughtbot.com>2015-01-05 14:46:27 -0700
commit00dad0343b3aa6cf019afe3c727d4a3d95ddc383 (patch)
tree0bf5a4f0f2edb0374665a67e8ce8f190c64391b5 /activerecord
parent3d0c718644181bc7c3912c8b2b9965aeaa408bc0 (diff)
downloadrails-00dad0343b3aa6cf019afe3c727d4a3d95ddc383.tar.gz
rails-00dad0343b3aa6cf019afe3c727d4a3d95ddc383.tar.bz2
rails-00dad0343b3aa6cf019afe3c727d4a3d95ddc383.zip
Define attribute methods before attempting to populate records
`initialize_internals_callback` will attempt to assign attributes from the current scope, which will fail if something defined the method and calls super (meaning it won't hit `method_missing`). Fixes #18339
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/core.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb
index 5c7c0feeb7..5a5139256d 100644
--- a/activerecord/lib/active_record/core.rb
+++ b/activerecord/lib/active_record/core.rb
@@ -276,11 +276,11 @@ module ActiveRecord
# User.new(first_name: 'Jamie')
def initialize(attributes = nil, options = {})
@attributes = self.class._default_attributes.dup
+ self.class.define_attribute_methods
init_internals
initialize_internals_callback
- self.class.define_attribute_methods
# +options+ argument is only needed to make protected_attributes gem easier to hook.
# Remove it when we drop support to this gem.
init_attributes(attributes, options) if attributes