From 00dad0343b3aa6cf019afe3c727d4a3d95ddc383 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Mon, 5 Jan 2015 14:45:14 -0700 Subject: 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 --- activerecord/lib/active_record/core.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord') 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 -- cgit v1.2.3